Changeset 1300 in tests
- Timestamp:
- 06/29/2013 10:31:15 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/bootstrap.php
r1232 r1300 18 18 19 19 // These are still needed 20 global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp ;20 global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer; 21 21 22 22 if ( !is_readable( $config_file_path ) ) { … … 41 41 42 42 $multisite = (int) ( defined( 'WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE ); 43 44 // Override the PHPMailer 45 require_once( dirname( __FILE__ ) . '/mock-mailer.php' ); 46 $phpmailer = new MockPHPMailer(); 43 47 44 48 system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $multisite ); -
trunk/includes/mock-mailer.php
r903 r1300 1 1 <?php 2 3 require_once(ABSPATH . '/wp-includes/class-phpmailer.php'); 2 require_once( ABSPATH . '/wp-includes/class-phpmailer.php' ); 4 3 5 4 class MockPHPMailer extends PHPMailer { … … 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.' ); 9 try { 10 if ( ! $this->PreSend() ) 11 return false; 12 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 ); 20 21 return true; 22 } catch ( phpmailerException $e ) { 12 23 return false; 13 24 } 14 15 // Set whether the message is multipart/alternative 16 if( ! empty($this->AltBody) ) 17 $this->ContentType = 'multipart/alternative'; 18 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' ); 26 return false; 27 } 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
r909 r1300 4 4 * @group pluggable 5 5 * @group mail 6 * @ticket UT477 6 */ 8 7 class Tests_Mail extends WP_UnitTestCase { … … 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 }
Note: See TracChangeset
for help on using the changeset viewer.