3131global $ CFG ;
3232require_once ($ CFG ->dirroot . '/mod/moodleoverflow/lib.php ' );
3333
34- class mod_moodleoverflow_dailymail_test extends \advanced_testcase {
35-
34+ class dailymail_test extends \advanced_testcase {
35+
3636 private $ sink ;
3737 private $ messagesink ;
3838 private $ course ;
3939 private $ user ;
4040 private $ moodleoverflow ;
4141 private $ discussion ;
42-
42+
4343 /**
4444 * Test setUp.
4545 */
@@ -55,8 +55,8 @@ public function setUp(): void {
5555
5656 // Create a new course with a moodleoverflow forum.
5757 $ 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 );
6060
6161 }
6262
@@ -77,7 +77,7 @@ public function helper_create_user_and_discussion($maildigest) {
7777 $ this ->user = $ this ->getDataGenerator ()->create_user (array ('firstname ' => 'Tamaro ' , 'maildigest ' => $ maildigest ));
7878 $ this ->getDataGenerator ()->enrol_user ($ this ->user ->id , $ this ->course ->id , 'student ' );
7979
80- //Create a new discussion and post within the moodleoverflow.
80+ // Create a new discussion and post within the moodleoverflow.
8181 $ generator = $ this ->getDataGenerator ()->get_plugin_generator ('mod_moodleoverflow ' );
8282 $ this ->discussion = $ generator ->post_to_forum ($ this ->moodleoverflow , $ this ->user );
8383 }
@@ -94,7 +94,7 @@ private function run_send_daily_mail() {
9494 ob_end_clean ();
9595 return $ output ;
9696 }
97-
97+
9898 /**
9999 * Run the send mails task.
100100 * @return false|string
@@ -118,11 +118,11 @@ public function test_mail_delivery() {
118118 $ this ->helper_create_user_and_discussion ('1 ' );
119119
120120 // 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
124124 $ messages = $ this ->sink ->count ();
125-
125+
126126 $ this ->assertEquals (1 , $ messages );
127127 }
128128
@@ -132,22 +132,22 @@ public function test_content_of_mail_delivery() {
132132 // Creat Users with maildigest = on.
133133 $ this ->helper_create_user_and_discussion ('1 ' );
134134
135- //send the mails and count the messages.
135+ // send the mails and count the messages.
136136 $ this ->run_send_mails ();
137137 $ content = $ this ->run_send_daily_mail ();
138138 $ 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.';.
142142 $ currentcourse = $ this ->course ->fullname ;
143143 $ currentforum = $ this ->moodleoverflow ->name ;
144144 $ 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);
151151 $ this ->assertStringContainsString ($ text , $ content );
152152 }
153153
@@ -160,7 +160,7 @@ public function test_mail_not_send() {
160160 $ this ->run_send_mails ();
161161 $ this ->run_send_daily_mail ();
162162 $ messages = $ this ->sink ->count ();
163-
164- $ this ->assertEquals (0 ,$ messages );
163+
164+ $ this ->assertEquals (0 , $ messages );
165165 }
166- }
166+ }
0 commit comments