WordPress.org

Make WordPress Core

Ticket #15448: 15448_Sept2015-unittests.diff

File 15448_Sept2015-unittests.diff, 1.3 KB (added by gitlost, 5 years ago)

Refresh of @MikeHansenMe patch 15448-unittests.diff for 4.4.

  • tests/phpunit/tests/mail.php

     
    8080        }
    8181
    8282        /**
     83         * @ticket 15448
     84         */
     85        function test_wp_mail_plain_and_html() {
     86                $to = 'user@example.com';
     87                $subject = 'Test email with plain text and html versions';
     88                $messages = array( 'text/plain' => 'Here is some plain text.',
     89                                           'text/html' =>'<html><head></head><body>Here is the HTML with UTF-8 γειά σου Κόσμε;-)<body></html>' );
     90
     91                wp_mail( $to, $subject, $messages );
     92
     93                preg_match( '/boundary="(.*)"/', $GLOBALS['phpmailer']->mock_sent[0]['header'], $matches);
     94                $boundry = $matches[1];
     95                $body = 'This is a multi-part message in MIME format.
     96
     97--' . $boundry . '
     98Content-Type: text/plain; charset=us-ascii
     99
     100Here is some plain text.
     101
     102
     103--' . $boundry . '
     104Content-Type: text/html; charset=UTF-8
     105Content-Transfer-Encoding: 8bit
     106
     107<html><head></head><body>Here is the HTML with UTF-8 γειά σου Κόσμε;-)<body></html>
     108
     109
     110
     111--' . $boundry . '--
     112';
     113                // We need some better assertions here but these test the behaviour for now.
     114                $this->assertEquals($body, $GLOBALS['phpmailer']->mock_sent[0]['body']);
     115        }
     116
     117        /**
    83118         * @ticket 17305
    84119         */
    85120        function test_wp_mail_rfc2822_addresses() {