Skip to content

Commit 08968b1

Browse files
committed
pull request error in dailymail_test.php fixed
1 parent 80fbb0e commit 08968b1

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

tests/dailymail_test.php

+14-12
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public function setUp(): void {
5757

5858
unset_config('noemailever');
5959
$this->sink = $this->redirectEmails();
60-
6160
$this->preventResetByRollback();
6261
$this->redirectMessages();
6362
// Create a new course with a moodleoverflow forum.
@@ -153,24 +152,27 @@ public function test_content_of_mail_delivery() {
153152

154153
// Send the mails and count the messages.
155154
$this->helper_run_send_mails();
156-
$content = $this->helper_run_send_daily_mail();
157-
$content = str_replace(["\n\r", "\n", "\r"], '', $content);
158-
$messages = $this->sink->count();
155+
$this->helper_run_send_daily_mail();
156+
$content = $this->sink->get_messages();
157+
$message = $content[0]->body;
158+
$message = str_replace(["\n\r", "\n", "\r"], '', $message);
159+
$messagecount = $this->sink->count();
159160

160161
// Build the text that the mail should have.
161162
// Text structure at get_string('digestunreadpost', moodleoverflow).
162-
$linktocourse = '<a href="https://www.example.com/moodle/course/view.php?id='
163-
. $this->course->id . '">' . $this->course->fullname . '</a>';
164-
$linktoforum = '<a href="https://www.example.com/moodle/mod/moodleoverflow/view.php?id='
165-
. $this->coursemodule->id . '">' . $this->moodleoverflow->name . '</a>';
166-
$linktodiscussion = '<a href="https://www.example.com/moodle/mod/moodleoverflow/discussion.php?d='
167-
. $this->discussion[0]->id . '">' . $this->discussion[0]->name . '</a>';
163+
$linktocourse = '<a href=3D"https://www.example.com/mood=le/course/view.php?id=3D'. $this->course->id;
164+
$linktoforum = '<a href=3D"https://www.=example.com/moodle/mod/moodleoverflow/view.php?id=3D'. $this->coursemodule->id;
165+
$linktodiscussion = '<a href=3D"https://www.example.com/moodle/mod/moodleoverflow/=discussion.php?d=3D'
166+
. $this->discussion[0]->id;
168167

169168
// Assemble text.
170169
$text = 'Course: ' . $linktocourse . ' -> ' . $linktoforum . ', Topic: '
171-
. $linktodiscussion . ' has ' . $messages . ' unread posts.';
170+
. $linktodiscussion . ' has ' . $messagecount . ' unread posts.';
172171

173-
$this->assertEquals($text, $content);
172+
$this->assertStringContainsString($linktocourse, $message);
173+
$this->assertStringContainsString($linktoforum, $message);
174+
$this->assertStringContainsString($linktodiscussion, $message);
175+
$this->assertStringContainsString($messagecount, $message);
174176
}
175177

176178

0 commit comments

Comments
 (0)