Ticket #24662: 24662.2.patch
File 24662.2.patch, 3.0 KB (added by , 11 years ago) |
---|
-
trunk/includes/bootstrap.php
41 41 42 42 $multisite = (int) ( defined( 'WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE ); 43 43 44 // Override the phpmailer 45 require_once( dirname( __FILE__ ) . '/mock-mailer.php' ); 46 $GLOBALS['phpmailer'] = new MockPHPMailer(); 47 44 48 system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $multisite ); 45 49 46 50 if ( $multisite ) { -
trunk/includes/mock-mailer.php
1 1 <?php 2 require_once( ABSPATH . '/wp-includes/class-phpmailer.php' ); 2 3 3 require_once(ABSPATH . '/wp-includes/class-phpmailer.php');4 5 4 class MockPHPMailer extends PHPMailer { 6 5 var $mock_sent = array(); 7 6 8 7 // override the Send function so it doesn't actually send anything 9 8 function Send() { 10 if ( (count($this->to) + count($this->cc) + count($this->bcc)) < 1 ) { 11 $this->SetError( 'You must provide at least one recipient email address.' ); 12 return false; 13 } 9 try { 10 if ( ! $this->PreSend() ) 11 return false; 14 12 15 // Set whether the message is multipart/alternative 16 if( ! empty($this->AltBody) ) 17 $this->ContentType = 'multipart/alternative'; 13 $this->mock_sent[] = array( 14 'to' => $this->to, 15 'cc' => $this->cc, 16 'bcc' => $this->bcc, 17 'header' => $this->MIMEHeader, 18 'body' => $this->MIMEBody, 19 ); 18 20 19 $this->error_count = 0; // reset errors 20 $this->SetMessageType(); 21 $header = $this->CreateHeader(); 22 $body = $this->CreateBody(); 23 24 if ( $body == '' ) { 25 $this->SetError( 'Message body empty' ); 21 return true; 22 } catch ( phpmailerException $e ) { 26 23 return false; 27 24 } 28 29 $this->mock_sent[] = array( 30 'to' => $this->to, 31 'cc' => $this->cc, 32 'bcc' => $this->bcc, 33 'header' => $header, 34 'body' => $body, 35 ); 36 37 return true; 38 } 25 } 39 26 } 40 41 ?> -
trunk/tests/mail.php
3 3 /** 4 4 * @group pluggable 5 5 * @group mail 6 * @ticket UT477 6 */ 8 7 class Tests_Mail extends WP_UnitTestCase { 9 8 function setUp() { … … 65 64 // We need some better assertions here but these catch the failure for now. 66 65 $this->assertEquals($body, $GLOBALS['phpmailer']->mock_sent[0]['body']); 67 66 $this->assertTrue(strpos($GLOBALS['phpmailer']->mock_sent[0]['header'], 'boundary="----=_Part_4892_25692638.1192452070893"') > 0); 68 $this->assertTrue(strpos($GLOBALS['phpmailer']->mock_sent[0]['header'], 'charset= ""') > 0);67 $this->assertTrue(strpos($GLOBALS['phpmailer']->mock_sent[0]['header'], 'charset=') > 0); 69 68 unset( $_SERVER['SERVER_NAME'] ); 70 69 } 71 70