Initialise $_SERVER['SERVER_NAME'] during the test bootstrap to avoid individual tests having to do it.

Fixes #34394


git-svn-id: https://develop.svn.wordpress.org/trunk@35350 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn
2015-10-21 23:51:45 +00:00
parent 2e1b898077
commit 82cb793355
6 changed files with 6 additions and 36 deletions

View File

@@ -110,8 +110,6 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
$this->start_transaction();
$this->expectDeprecated();
add_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) );
add_filter( 'wp_mail', array( $this, 'set_wp_mail_globals' ) );
}
/**
@@ -668,32 +666,6 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
return array_sum( $time_array );
}
/**
* When `wp_mail()` is called, make sure `$_SERVER['SERVER_NAME']` is faked.
*
* @since 4.3.0
*
* @param array $args `wp_mail()` arguments.
* @return array $args
*/
public function set_wp_mail_globals( $args ) {
if ( ! isset( $_SERVER['SERVER_NAME'] ) ) {
$_SERVER['SERVER_NAME'] = 'example.com';
add_action( 'phpmailer_init', array( $this, 'tear_down_wp_mail_globals' ) );
}
return $args;
}
/**
* Tear down the faked `$_SERVER['SERVER_NAME']` global used in `wp_mail()`.
*
* @since 4.3.0
*/
public function tear_down_wp_mail_globals() {
unset( $_SERVER['SERVER_NAME'] );
}
/**
* Multisite-agnostic way to delete a user from the database.
*