Changeset 32839 for trunk/tests/phpunit/includes/testcase.php
- Timestamp:
- 06/18/2015 01:52:29 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/testcase.php
r31515 r32839 54 54 $this->expectDeprecated(); 55 55 add_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) ); 56 57 add_filter( 'wp_mail', array( $this, 'set_wp_mail_globals' ) ); 56 58 } 57 59 … … 570 572 return array_sum( $time_array ); 571 573 } 574 575 /** 576 * When `wp_mail()` is called, make sure `$_SERVER['SERVER_NAME']` is faked. 577 * 578 * @since 4.3.0 579 * 580 * @param array $args `wp_mail()` arguments. 581 * @return array $args 582 */ 583 public function set_wp_mail_globals( $args ) { 584 if ( ! isset( $_SERVER['SERVER_NAME'] ) ) { 585 $_SERVER['SERVER_NAME'] = 'example.com'; 586 add_action( 'phpmailer_init', array( $this, 'tear_down_wp_mail_globals' ) ); 587 } 588 589 return $args; 590 } 591 592 /** 593 * Tear down the faked `$_SERVER['SERVER_NAME']` global used in `wp_mail()`. 594 * 595 * @since 4.3.0 596 */ 597 public function tear_down_wp_mail_globals() { 598 unset( $_SERVER['SERVER_NAME'] ); 599 } 572 600 }
Note: See TracChangeset
for help on using the changeset viewer.