@@ -57,7 +57,6 @@ public function setUp(): void {
57
57
58
58
unset_config ('noemailever ' );
59
59
$ this ->sink = $ this ->redirectEmails ();
60
-
61
60
$ this ->preventResetByRollback ();
62
61
$ this ->redirectMessages ();
63
62
// Create a new course with a moodleoverflow forum.
@@ -153,24 +152,27 @@ public function test_content_of_mail_delivery() {
153
152
154
153
// Send the mails and count the messages.
155
154
$ 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 ();
159
160
160
161
// Build the text that the mail should have.
161
162
// 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 ;
168
167
169
168
// Assemble text.
170
169
$ text = 'Course: ' . $ linktocourse . ' -> ' . $ linktoforum . ', Topic: '
171
- . $ linktodiscussion . ' has ' . $ messages . ' unread posts. ' ;
170
+ . $ linktodiscussion . ' has ' . $ messagecount . ' unread posts. ' ;
172
171
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 );
174
176
}
175
177
176
178
0 commit comments