33 * @group mail
44 * @covers WP_Mailer
55 */
6- class Tests_Mail_WPMailer extends WP_UnitTestCase {
6+ class Tests_Mail_WP_Mailer extends WP_UnitTestCase {
77
88 public function set_up () {
99 parent ::set_up ();
@@ -69,7 +69,7 @@ public function test_send_registered_email() {
6969
7070 /**
7171 * Tests the Reply-To fix in wp_mail.
72- *
72+ *
7373 * @ticket 49661
7474 */
7575 public function test_wp_mail_reply_to_quoting_fix () {
@@ -80,25 +80,25 @@ public function test_wp_mail_reply_to_quoting_fix() {
8080
8181 wp_mail ( $ to , $ subject , $ message , $ headers );
8282
83- $ mailer = tests_retrieve_phpmailer_instance ();
83+ $ mailer = tests_retrieve_phpmailer_instance ();
8484 $ reply_tos = $ mailer ->getReplyToAddresses ();
85-
85+
8686 $ this ->assertCount ( 1 , $ reply_tos );
8787 $ reply_to = reset ( $ reply_tos );
88-
88+
8989 // PHPMailer will add its own quotes if needed, but we should not have double quotes here.
90- $ this ->assertSame ( 'john@example.com ' , $ reply_to [0 ] );
91- $ this ->assertSame ( 'John Doe ' , $ reply_to [1 ] );
90+ $ this ->assertSame ( 'john@example.com ' , $ reply_to [ 0 ] );
91+ $ this ->assertSame ( 'John Doe ' , $ reply_to [ 1 ] );
9292 }
9393
9494 /**
9595 * Tests the retrieve_password template logic.
9696 */
9797 public function test_retrieve_password_template () {
98- $ site_name = 'My Awesome Site ' ;
98+ $ site_name = 'My Awesome Site ' ;
9999 $ user_login = 'alice ' ;
100- $ reset_url = 'https://example.com/reset ' ;
101- $ ip = '127.0.0.1 ' ;
100+ $ reset_url = 'https://example.com/reset ' ;
101+ $ ip = '127.0.0.1 ' ;
102102
103103 WP_Mailer::register_email (
104104 'retrieve_password ' ,
@@ -131,34 +131,50 @@ public function test_retrieve_password_template() {
131131 * Tests the new_user templates.
132132 */
133133 public function test_new_user_templates () {
134- // Admin notification
135- WP_Mailer::register_email ( 'new_user_admin ' , 'admin ' , array (
136- 'subject ' => '[{{sitename}}] New User ' ,
137- 'body ' => 'User: {{user_login}} Email: {{user_email}} ' ,
138- ));
139-
140- WP_Mailer::send ( 'new_user_admin ' , array ( 'to ' => 'admin@example.com ' ), array (
141- 'sitename ' => 'Site ' ,
142- 'user_login ' => 'bob ' ,
143- 'user_email ' => 'bob@example.com ' ,
144- ) );
134+ // Admin notification.
135+ WP_Mailer::register_email (
136+ 'new_user_admin ' ,
137+ 'admin ' ,
138+ array (
139+ 'subject ' => '[{{sitename}}] New User ' ,
140+ 'body ' => 'User: {{user_login}} Email: {{user_email}} ' ,
141+ )
142+ );
143+
144+ WP_Mailer::send (
145+ 'new_user_admin ' ,
146+ array ( 'to ' => 'admin@example.com ' ),
147+ array (
148+ 'sitename ' => 'Site ' ,
149+ 'user_login ' => 'bob ' ,
150+ 'user_email ' => 'bob@example.com ' ,
151+ )
152+ );
145153
146154 $ mailer = tests_retrieve_phpmailer_instance ();
147155 $ this ->assertSame ( '[Site] New User ' , $ mailer ->Subject );
148156 $ this ->assertStringContainsString ( 'User: bob ' , $ mailer ->get_sent ()->body );
149157
150- // User notification
158+ // User notification.
151159 reset_phpmailer_instance ();
152- WP_Mailer::register_email ( 'new_user ' , 'user ' , array (
153- 'subject ' => '[{{sitename}}] Login Details ' ,
154- 'body ' => 'Login: {{user_login}} URL: {{set_password_url}} ' ,
155- ));
156-
157- WP_Mailer::send ( 'new_user ' , array ( 'to ' => 'bob@example.com ' ), array (
158- 'sitename ' => 'Site ' ,
159- 'user_login ' => 'bob ' ,
160- 'set_password_url ' => 'http://example.com/set-pw ' ,
161- ) );
160+ WP_Mailer::register_email (
161+ 'new_user ' ,
162+ 'user ' ,
163+ array (
164+ 'subject ' => '[{{sitename}}] Login Details ' ,
165+ 'body ' => 'Login: {{user_login}} URL: {{set_password_url}} ' ,
166+ )
167+ );
168+
169+ WP_Mailer::send (
170+ 'new_user ' ,
171+ array ( 'to ' => 'bob@example.com ' ),
172+ array (
173+ 'sitename ' => 'Site ' ,
174+ 'user_login ' => 'bob ' ,
175+ 'set_password_url ' => 'http://example.com/set-pw ' ,
176+ )
177+ );
162178
163179 $ mailer = tests_retrieve_phpmailer_instance ();
164180 $ this ->assertSame ( '[Site] Login Details ' , $ mailer ->Subject );
0 commit comments