WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/27/17 14:58:06 (6 months ago)
Author:
johnbillion
Message:

Users: Further fixes to entitiy decoding in the user email address change confirmation email, and the corresponding tests.

See #16470, #40015

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user.php

    r41163 r41171  
    12731273        $this->assertEquals( $_POST['email'], 'after@example.com' ); 
    12741274    } 
     1275 
     1276    /** 
     1277     * Ensure user email address change confirmation emails do not contain encoded HTML entities 
     1278     * 
     1279     * @ticket 16470 
     1280     * @ticket 40015 
     1281     */ 
     1282    function test_send_confirmation_on_profile_email_html_entities_decoded() { 
     1283        $user_id = self::factory()->user->create( array( 
     1284            'role'       => 'subscriber', 
     1285            'user_email' => 'old-email@test.dev', 
     1286        ) ); 
     1287        wp_set_current_user( $user_id ); 
     1288 
     1289        reset_phpmailer_instance(); 
     1290 
     1291        // Give the site and blog a name containing HTML entities 
     1292        update_site_option( 'site_name', ''Test' site's "name" has <html entities> &' ); 
     1293        update_option( 'blogname', ''Test' blog's "name" has <html entities> &' ); 
     1294 
     1295        // Set $_POST['email'] with new e-mail and $_POST['user_id'] with user's ID. 
     1296        $_POST['user_id'] = $user_id; 
     1297        $_POST['email']   = 'new-email@test.dev'; 
     1298 
     1299        send_confirmation_on_profile_email( ); 
     1300 
     1301        $mailer = tests_retrieve_phpmailer_instance(); 
     1302 
     1303        $recipient = $mailer->get_recipient( 'to' ); 
     1304        $email     = $mailer->get_sent(); 
     1305 
     1306        // Assert recipient is correct 
     1307        $this->assertSame( 'new-email@test.dev', $recipient->address, 'User email change confirmation recipient not as expected' ); 
     1308 
     1309        // Assert that HTML entites have been decoded in body and subject 
     1310        if ( is_multisite() ) { 
     1311            $this->assertContains( '\'Test\' site\'s "name" has <html entities> &', $email->body, 'Email body does not contain the decoded HTML entities' ); 
     1312            $this->assertNotContains( '&#039;Test&#039; site&#039;s &quot;name&quot; has &lt;html entities&gt; &amp;', $email->body, 'Email body does contains HTML entities' ); 
     1313        } 
     1314 
     1315        $this->assertContains( '\'Test\' blog\'s "name" has <html entities> &', $email->subject, 'Email subject does not contain the decoded HTML entities' ); 
     1316        $this->assertNotContains( '&#039;Test&#039; blog&#039;s &quot;name&quot; has &lt;html entities&gt; &amp;', $email->subject, 'Email subject does contains HTML entities' ); 
     1317    } 
    12751318} 
Note: See TracChangeset for help on using the changeset viewer.