WordPress.org

Make WordPress Core

Changeset 322 in tests


Ignore:
Timestamp:
12/15/2010 12:47:34 PM (7 years ago)
Author:
westi
Message:

Add a basic test for the new functionality proposed in #WP15448

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_pluggable.php

    r321 r322  
    9898    }
    9999   
     100    function test_wp_mail_plain_and_html() {
     101        $this->knownWPBug(15448);
     102
     103        $to = 'user@example.com';
     104        $subject = 'Test email with plain text and html versions';
     105        $messages = array( 'text/plain' => 'Here is some plain text.',
     106                       'text/html' =>'<html><head></head><body>Here is the HTML ;-)<body></html>' );
     107       
     108        unset($GLOBALS['phpmailer']->mock_sent);
     109        $_SERVER['SERVER_NAME'] = 'example.com';
     110        wp_mail( $to, $subject, $messages );
     111
     112        preg_match( '/boundary="(.*)"/', $GLOBALS['phpmailer']->mock_sent[0]['header'], $matches);
     113        $boundry = $matches[1];
     114        $body = '--' . $boundry . '
     115Content-Type: text/plain; charset = "UTF-8"
     116Content-Transfer-Encoding: 8bit
     117
     118Here is some plain text.
     119
     120
     121--' . $boundry . '
     122Content-Type: text/html; charset = "UTF-8"
     123Content-Transfer-Encoding: 8bit
     124
     125<html><head></head><body>Here is the HTML ;-)<body></html>
     126
     127
     128
     129--' . $boundry . '--
     130';
     131        // We need some better assertions here but these test the behaviour for now.
     132        $this->assertEquals($body, $GLOBALS['phpmailer']->mock_sent[0]['body']);
     133        unset( $_SERVER['SERVER_NAME'] );
     134    }
     135   
    100136}
    101137
Note: See TracChangeset for help on using the changeset viewer.