Skip to content

Commit 2d1ec28

Browse files
committed
upd: subscription mail tests
1 parent 8f7d934 commit 2d1ec28

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/phpunit/tests/user.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,13 +1861,14 @@ public function test_send_confirmation_on_profile_email() {
18611861
*
18621862
* @ticket 54416
18631863
*/
1864-
public function test_send_confirmation_on_profile_email_with_apostrophe() {
1864+
public function test_send_confirmation_on_profile_email_with_special_chars() {
18651865
reset_phpmailer_instance();
18661866
$was_confirmation_email_sent = false;
18671867

18681868
$user = self::factory()->user->create_and_get(
18691869
array(
1870-
'user_email' => 'user@example.com',
1870+
'role' => 'subscriber',
1871+
'user_email' => 'before@example.com',
18711872
)
18721873
);
18731874

@@ -1878,23 +1879,22 @@ public function test_send_confirmation_on_profile_email_with_apostrophe() {
18781879

18791880
do_action( 'personal_options_update' );
18801881

1881-
$mailer = tests_retrieve_phpmailer_instance();
1882-
1883-
$recipient = $mailer->get_recipient( 'to' );
1884-
if ( $recipient ) {
1885-
$was_confirmation_email_sent = ( "o'connor@example.com" === $recipient->address );
1882+
if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
1883+
$was_confirmation_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && "o'connor@example.com" === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
18861884
}
18871885

1886+
// A confirmation email is sent.
18881887
$this->assertTrue( $was_confirmation_email_sent );
1889-
$this->assertSame( "o'connor@example.com", $recipient->address );
18901888

1889+
// The new email address gets put into user_meta.
18911890
$new_email_meta = get_user_meta( $user->ID, '_new_email', true );
18921891
$this->assertSame( "o'connor@example.com", $new_email_meta['newemail'] );
18931892

1894-
$sent_email = $mailer->get_sent();
1895-
$this->assertStringContainsString( "o'connor@example.com", $sent_email->header );
1893+
// The email address of the user doesn't change. $_POST['email'] should be the email address pre-update.
1894+
$this->assertSame( $_POST['email'], $user->user_email );
18961895
}
18971896

1897+
18981898
/**
18991899
* @ticket 16470
19001900
*/

0 commit comments

Comments
 (0)