Skip to content

Commit a667dff

Browse files
committed
add login for right file saving
1 parent 20c78e9 commit a667dff

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

tests/discussion_test.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ public function test_create_discussion(): void {
9191
$prepost->formattachments = '';
9292
$prepost->modulecontext = $this->modulecontext;
9393

94+
// Log in as the teacher.
95+
$this->setUser($this->teacher);
96+
9497
// Build a new discussion object.
9598
$discussion = discussion::construct_without_id($this->course->id, $this->moodleoverflow->id, 'Discussion Topic',
9699
0, $this->teacher->id, $time, $time, $this->teacher->id);

tests/post_test.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public function tearDown(): void {
8585
*/
8686
public function test_create_post(): void {
8787
global $DB;
88+
89+
// Log in as the teacher.
90+
$this->setUser($this->teacher);
91+
8892
// Build a new post object.
8993
$time = time();
9094
$message = 'a unique message';
@@ -103,6 +107,9 @@ public function test_create_post(): void {
103107
public function test_edit_post(): void {
104108
global $DB;
105109

110+
// Log in as the teacher.
111+
$this->setUser($this->teacher);
112+
106113
// The post and the attachment should exist.
107114
$numberofattachments = count($DB->get_records('files', ['itemid' => $this->post->get_id()]));
108115
$this->assertEquals(2, $numberofattachments); // One Attachment is saved twice in 'files'.

0 commit comments

Comments
 (0)