WordPress.org

Make WordPress Core

Ticket #39360: 39360-tests.diff

File 39360-tests.diff, 773 bytes (added by xknown, 5 years ago)

Unit tests to reproduce this issue.

  • tests/phpunit/tests/mail.php

    diff --git a/tests/phpunit/tests/mail.php b/tests/phpunit/tests/mail.php
    index 1522594..316d67e 100644
    a b class Tests_Mail extends WP_UnitTestCase { 
    392392                $this->assertEquals( 'wp_mail_failed', $call_args[0]->get_error_code() );
    393393                $this->assertEquals( $expected_error_data, $call_args[0]->get_error_data() );
    394394        }
     395
     396        /**
     397         * @ticket 39360
     398         */
     399        public function test_wpmail_invalid_from_address_should_not_throw_exception() {
     400                $_SERVER['SERVER_NAME'] = '_';
     401                $to = 'user@example.org';
     402
     403                $ma = new MockAction();
     404                add_action( 'wp_mail_failed', array( &$ma, 'action' ) );
     405                wp_mail( $to, 'Testing', 'Test Message' );
     406
     407                $this->assertEquals( 1, $ma->get_call_count() );
     408        }
    395409}