Skip to content

Commit 1b747e7

Browse files
Fix privacy testcase
1 parent 455c4cd commit 1b747e7

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

tests/generator/lib.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function create_post($record = null, $straighttodb = true) {
233233
if ($straighttodb) {
234234
$record->id = $DB->insert_record('moodleoverflow_posts', $record);
235235
} else {
236-
$record->id = moodleoverflow_add_new_post($record, );
236+
$record->id = moodleoverflow_add_new_post($record);
237237
}
238238
// Update the last post.
239239
moodleoverflow_discussion_update_last_post($record->discussion);
@@ -369,18 +369,17 @@ public function post_to_discussion($forum, $discussion, $author) {
369369
*
370370
* @param stdClass $parent The parent post
371371
* @param stdClass $author The author to post as
372+
* @param bool $straighttodb
372373
*
373374
* @return stdClass The new moodleoverflow post
374375
*/
375-
public function reply_to_post($parent, $author) {
376+
public function reply_to_post($parent, $author, $straighttodb = true) {
376377
// Add a post to the discussion.
377378
$record = (object) [
378379
'discussion' => $parent->discussion,
379380
'parent' => $parent->id,
380381
'userid' => $author->id
381382
];
382-
$post = $this->create_post($record, false);
383-
384-
return $post;
383+
return $this->create_post($record, $straighttodb);
385384
}
386385
}

tests/review_test.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ public function test_forum_review_everything() {
125125

126126
$this->messagesink->clear();
127127

128-
$studentanswer1 = $this->generator->reply_to_post($teacherpost, $this->student);
129-
$studentanswer2 = $this->generator->reply_to_post($teacherpost, $this->student);
128+
$studentanswer1 = $this->generator->reply_to_post($teacherpost, $this->student, false);
129+
$studentanswer2 = $this->generator->reply_to_post($teacherpost, $this->student, false);
130130

131131
$this->run_send_mails();
132132
$this->run_send_mails(); // Execute twice to ensure no duplicate mails.
@@ -200,8 +200,8 @@ public function test_forum_review_only_questions() {
200200

201201
$this->messagesink->clear();
202202

203-
$studentanswer1 = $this->generator->reply_to_post($teacherpost, $this->student);
204-
$studentanswer2 = $this->generator->reply_to_post($teacherpost, $this->student);
203+
$studentanswer1 = $this->generator->reply_to_post($teacherpost, $this->student, false);
204+
$studentanswer2 = $this->generator->reply_to_post($teacherpost, $this->student, false);
205205

206206
$this->assert_matches_properties(['mailed' => MOODLEOVERFLOW_MAILED_PENDING, 'reviewed' => 1, 'timereviewed' => null],
207207
$DB->get_record('moodleoverflow_posts', ['id' => $studentanswer1->id]));
@@ -254,8 +254,8 @@ public function test_forum_review_disallowed() {
254254
$this->mailsink->clear();
255255
$this->messagesink->clear();
256256

257-
$studentanswer1 = $this->generator->reply_to_post($teacherpost, $this->student);
258-
$studentanswer2 = $this->generator->reply_to_post($teacherpost, $this->student);
257+
$studentanswer1 = $this->generator->reply_to_post($teacherpost, $this->student, false);
258+
$studentanswer2 = $this->generator->reply_to_post($teacherpost, $this->student, false);
259259

260260
$this->assert_matches_properties(['mailed' => MOODLEOVERFLOW_MAILED_PENDING, 'reviewed' => 1, 'timereviewed' => null],
261261
$DB->get_record('moodleoverflow_posts', ['id' => $studentanswer1->id]));

0 commit comments

Comments
 (0)