Changeset 25381
- Timestamp:
- 09/12/2013 04:46:49 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/mail.php
r25264 r25381 1 1 <?php 2 3 2 /** 4 3 * @group pluggable … … 8 7 function setUp() { 9 8 parent::setUp(); 9 $_SERVER['SERVER_NAME'] = 'example.com'; 10 unset( $GLOBALS['phpmailer']->mock_sent ); 11 } 12 13 function tearDown() { 14 parent::tearDown(); 15 unset( $_SERVER['SERVER_NAME'] ); 10 16 } 11 17 … … 58 64 $body .= "\n"; 59 65 60 unset($GLOBALS['phpmailer']->mock_sent);61 $_SERVER['SERVER_NAME'] = 'example.com';62 66 wp_mail($to, $subject, $body, $headers); 63 67 … … 66 70 $this->assertTrue(strpos($GLOBALS['phpmailer']->mock_sent[0]['header'], 'boundary="----=_Part_4892_25692638.1192452070893"') > 0); 67 71 $this->assertTrue(strpos($GLOBALS['phpmailer']->mock_sent[0]['header'], 'charset=') > 0); 68 unset( $_SERVER['SERVER_NAME'] );69 72 } 70 73 … … 73 76 */ 74 77 function test_wp_mail_plain_and_html() { 75 76 78 $to = 'user@example.com'; 77 79 $subject = 'Test email with plain text and html versions'; … … 79 81 'text/html' =>'<html><head></head><body>Here is the HTML ;-)<body></html>' ); 80 82 81 unset($GLOBALS['phpmailer']->mock_sent);82 $_SERVER['SERVER_NAME'] = 'example.com';83 83 wp_mail( $to, $subject, $messages ); 84 84 … … 104 104 // We need some better assertions here but these test the behaviour for now. 105 105 $this->assertEquals($body, $GLOBALS['phpmailer']->mock_sent[0]['body']); 106 unset( $_SERVER['SERVER_NAME'] );107 106 } 108 107 … … 111 110 */ 112 111 function test_wp_mail_rfc2822_addresses() { 113 114 112 $to = "Name <address@tld.com>"; 115 113 $from = "Another Name <another_address@different-tld.com>"; … … 122 120 $headers[] = "BCC: {$bcc}"; 123 121 124 unset($GLOBALS['phpmailer']->mock_sent);125 $_SERVER['SERVER_NAME'] = 'example.com';126 122 wp_mail( $to, $subject, $message, $headers ); 127 123 … … 134 130 $this->assertEquals('bcc@bcc.com', $GLOBALS['phpmailer']->mock_sent[0]['bcc'][0][0]); 135 131 $this->assertEquals('The Blind Carbon Guy', $GLOBALS['phpmailer']->mock_sent[0]['bcc'][0][1]); 136 137 132 $this->assertEquals($message . "\n", $GLOBALS['phpmailer']->mock_sent[0]['body']); 138 unset( $_SERVER['SERVER_NAME'] );139 133 } 140 134 … … 143 137 */ 144 138 function test_wp_mail_multiple_rfc2822_to_addresses() { 145 146 139 $to = "Name <address@tld.com>, Another Name <another_address@different-tld.com>"; 147 140 $subject = "RFC2822 Testing"; 148 141 $message = "My RFC822 Test Message"; 149 142 150 unset($GLOBALS['phpmailer']->mock_sent);151 $_SERVER['SERVER_NAME'] = 'example.com';152 143 wp_mail( $to, $subject, $message ); 153 144 … … 158 149 $this->assertEquals('another_address@different-tld.com', $GLOBALS['phpmailer']->mock_sent[0]['to'][1][0]); 159 150 $this->assertEquals('Another Name', $GLOBALS['phpmailer']->mock_sent[0]['to'][1][1]); 160 161 151 $this->assertEquals($message . "\n", $GLOBALS['phpmailer']->mock_sent[0]['body']); 162 unset( $_SERVER['SERVER_NAME'] );163 152 } 164 153 … … 168 157 $message = "My RFC822 Test Message"; 169 158 170 unset($GLOBALS['phpmailer']->mock_sent);171 $_SERVER['SERVER_NAME'] = 'example.com';172 159 wp_mail( $to, $subject, $message ); 173 160 … … 175 162 $this->assertEquals('another_address@different-tld.com', $GLOBALS['phpmailer']->mock_sent[0]['to'][1][0]); 176 163 $this->assertEquals($message . "\n", $GLOBALS['phpmailer']->mock_sent[0]['body']); 177 unset( $_SERVER['SERVER_NAME'] );178 164 } 179 165 … … 182 168 */ 183 169 function test_wp_mail_to_address_no_name() { 184 185 170 $to = "<address@tld.com>"; 186 171 $subject = "RFC2822 Testing"; 187 172 $message = "My RFC822 Test Message"; 188 173 189 unset($GLOBALS['phpmailer']->mock_sent);190 $_SERVER['SERVER_NAME'] = 'example.com';191 174 wp_mail( $to, $subject, $message ); 192 175 193 176 $this->assertEquals('address@tld.com', $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]); 194 195 177 $this->assertEquals($message . "\n", $GLOBALS['phpmailer']->mock_sent[0]['body']); 196 unset( $_SERVER['SERVER_NAME'] );197 178 } 198 179
Note: See TracChangeset
for help on using the changeset viewer.