Make WordPress Core

Ticket #23291: 23291-unit-tests.diff

File 23291-unit-tests.diff, 1.3 KB (added by iandunn, 12 years ago)
  • tests/mail.php

     
    210210                $this->assertEquals($message . "\n", $GLOBALS['phpmailer']->mock_sent[0]['body']);
    211211                unset( $_SERVER['SERVER_NAME'] );
    212212        }
     213       
     214        /**
     215         * @ticket 23291
     216         */
     217        function test_wp_mail_return_true_with_non_fatal_errors_by_default() {
     218                $result = wp_mail( 'valid@address.com', 'subject', 'body', "Cc: invalid-address\nBcc: @invalid.address", ABSPATH . '/non-existant-file.html' );
     219                $this->assertTrue( $result );
     220        }
     221       
     222        /**
     223         * @ticket 23291
     224         */
     225        function test_wp_mail_return_wp_error_for_fatal_errors_when_requested() {
     226                $result = wp_mail( 'invalid.address', 'subject', 'body', '', array(), 'wp_error' );
     227                $this->assertWPError( $result );
     228        }
     229
     230        /**
     231         * @ticket 23291
     232         */     
     233        function test_wp_mail_return_wp_error_for_non_fatal_errors_when_requested()
     234        {
     235                $result = wp_mail( 'valid@address.com', 'subject', 'body', "Cc: invalid_address\nBcc: another_invalid_address", array( '/this/file/does/not/exist' ), 'wp_error' );
     236                $this->assertWPError( $result );
     237                $this->assertCount( 3, $result->get_error_codes() );
     238                $this->assertNotContains( 'mailer_send', $result->get_error_messages() );
     239        }
    213240}