31
31
global $ CFG ;
32
32
require_once ($ CFG ->dirroot . '/mod/moodleoverflow/lib.php ' );
33
33
34
- class mod_moodleoverflow_dailymail_test extends \advanced_testcase {
35
-
34
+ class dailymail_test extends \advanced_testcase {
35
+
36
36
private $ sink ;
37
37
private $ messagesink ;
38
38
private $ course ;
39
39
private $ user ;
40
40
private $ moodleoverflow ;
41
41
private $ discussion ;
42
-
42
+
43
43
/**
44
44
* Test setUp.
45
45
*/
@@ -55,8 +55,8 @@ public function setUp(): void {
55
55
56
56
// Create a new course with a moodleoverflow forum.
57
57
$ this ->course = $ this ->getDataGenerator ()->create_course ();
58
- $ location = array ('course ' => $ this ->course ->id ,'forcesubscribe ' => MOODLEOVERFLOW_FORCESUBSCRIBE );
59
- $ this ->moodleoverflow = $ this ->getDataGenerator ()->create_module ('moodleoverflow ' ,$ location );
58
+ $ location = array ('course ' => $ this ->course ->id , 'forcesubscribe ' => MOODLEOVERFLOW_FORCESUBSCRIBE );
59
+ $ this ->moodleoverflow = $ this ->getDataGenerator ()->create_module ('moodleoverflow ' , $ location );
60
60
61
61
}
62
62
@@ -77,7 +77,7 @@ public function helper_create_user_and_discussion($maildigest) {
77
77
$ this ->user = $ this ->getDataGenerator ()->create_user (array ('firstname ' => 'Tamaro ' , 'maildigest ' => $ maildigest ));
78
78
$ this ->getDataGenerator ()->enrol_user ($ this ->user ->id , $ this ->course ->id , 'student ' );
79
79
80
- //Create a new discussion and post within the moodleoverflow.
80
+ // Create a new discussion and post within the moodleoverflow.
81
81
$ generator = $ this ->getDataGenerator ()->get_plugin_generator ('mod_moodleoverflow ' );
82
82
$ this ->discussion = $ generator ->post_to_forum ($ this ->moodleoverflow , $ this ->user );
83
83
}
@@ -94,7 +94,7 @@ private function run_send_daily_mail() {
94
94
ob_end_clean ();
95
95
return $ output ;
96
96
}
97
-
97
+
98
98
/**
99
99
* Run the send mails task.
100
100
* @return false|string
@@ -118,11 +118,11 @@ public function test_mail_delivery() {
118
118
$ this ->helper_create_user_and_discussion ('1 ' );
119
119
120
120
// Send a mail and test if the mail was sent.
121
-
122
- $ this ->run_send_mails (); //content2
123
- $ this ->run_send_daily_mail (); //content
121
+
122
+ $ this ->run_send_mails (); // content2
123
+ $ this ->run_send_daily_mail (); // content
124
124
$ messages = $ this ->sink ->count ();
125
-
125
+
126
126
$ this ->assertEquals (1 , $ messages );
127
127
}
128
128
@@ -132,22 +132,22 @@ public function test_content_of_mail_delivery() {
132
132
// Creat Users with maildigest = on.
133
133
$ this ->helper_create_user_and_discussion ('1 ' );
134
134
135
- //send the mails and count the messages.
135
+ // send the mails and count the messages.
136
136
$ this ->run_send_mails ();
137
137
$ content = $ this ->run_send_daily_mail ();
138
138
$ messages = $ this ->sink ->count ();
139
-
140
- //Build the text that the mail should have.
141
- //Text structure: $string['digestunreadpost'] = 'Course: {$a->currentcourse} -> {$a->currentforum}, Topic: {$a->discussion} has {$a->unreadposts} unread posts.';.
139
+
140
+ // Build the text that the mail should have.
141
+ // Text structure: $string['digestunreadpost'] = 'Course: {$a->currentcourse} -> {$a->currentforum}, Topic: {$a->discussion} has {$a->unreadposts} unread posts.';.
142
142
$ currentcourse = $ this ->course ->fullname ;
143
143
$ currentforum = $ this ->moodleoverflow ->name ;
144
144
$ currentdiscussion = $ this ->discussion [0 ]->name ;
145
- $ text = 'Course: ' . $ currentcourse . ' -> ' . $ currentforum . ', Topic: ' . $ currentdiscussion . ' has ' . $ messages . ' unread posts. ' ;
146
- $ content = str_replace ("\r\n" ,"" ,$ content );
147
- $ text = str_replace ("\r\n" ,"" ,$ text );
148
-
149
- //$this->assertisInt(0, strcmp($text, $content)); //strcmp compares 2 strings and retuns 0 if equal
150
- //$this->assertEquals($text, $content);
145
+ $ text = 'Course: ' . $ currentcourse . ' -> ' . $ currentforum . ', Topic: ' . $ currentdiscussion . ' has ' . $ messages . ' unread posts. ' ;
146
+ $ content = str_replace ("\r\n" , "" , $ content );
147
+ $ text = str_replace ("\r\n" , "" , $ text );
148
+
149
+ // $this->assertisInt(0, strcmp($text, $content)); //strcmp compares 2 strings and retuns 0 if equal
150
+ // $this->assertEquals($text, $content);
151
151
$ this ->assertStringContainsString ($ text , $ content );
152
152
}
153
153
@@ -160,7 +160,7 @@ public function test_mail_not_send() {
160
160
$ this ->run_send_mails ();
161
161
$ this ->run_send_daily_mail ();
162
162
$ messages = $ this ->sink ->count ();
163
-
164
- $ this ->assertEquals (0 ,$ messages );
163
+
164
+ $ this ->assertEquals (0 , $ messages );
165
165
}
166
- }
166
+ }
0 commit comments