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/multisite.php

    r41170 r41171  
    496496            ) 
    497497        ); 
    498     } 
    499  
    500     /** 
    501      * Ensure email change confirmation emails do not contain encoded HTML entities 
    502      * @ticket 40015 
    503      */ 
    504     function test_ms_send_confirmation_on_profile_email_html_entities_decoded() { 
    505  
    506         $old_current = get_current_user_id(); 
    507         $user_id = self::factory()->user->create( array( 
    508             'role'       => 'subscriber', 
    509             'user_email' => 'old-email@test.dev', 
    510         ) ); 
    511         wp_set_current_user( $user_id ); 
    512  
    513         reset_phpmailer_instance(); 
    514  
    515         // Give the site and blog a name containing HTML entities 
    516         update_site_option( 'site_name', ''Test' site's "name" has <html entities> &' ); 
    517         update_option( 'blogname', ''Test' blog's "name" has <html entities> &' ); 
    518  
    519         // Set $_POST['email'] with new e-mail and $_POST['id'] with user's ID. 
    520         $_POST['user_id'] = $user_id; 
    521         $_POST['email'] = 'new-email@test.dev'; 
    522         send_confirmation_on_profile_email( ); 
    523  
    524         $mailer = tests_retrieve_phpmailer_instance(); 
    525  
    526         $recipient = $mailer->get_recipient( 'to' ); 
    527         $email = $mailer->get_sent(); 
    528  
    529         // Assert reciepient is correct 
    530         $this->assertSame( 'new-email@test.dev', $recipient->address, 'Admin email change notification recipient not as expected' ); 
    531  
    532         // Assert that HTML entites have been decode in body and subject 
    533         $this->assertContains( '\'Test\' site\'s "name" has <html entities> &', $email->body, 'Email body does not contain the decoded HTML entities' ); 
    534         $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' ); 
    535         $this->assertContains( '\'Test\' blog\'s "name" has <html entities> &', $email->subject, 'Email subject does not contain the decoded HTML entities' ); 
    536         $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' ); 
    537  
    538         wp_set_current_user( $old_current ); 
    539498    } 
    540499 
Note: See TracChangeset for help on using the changeset viewer.