Changeset 7664 for trunk/tests/includes/testcase.php
- Timestamp:
- 12/12/2013 08:43:28 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/includes/testcase.php
r7497 r7664 12 12 13 13 protected $temp_has_bp_moderate = array(); 14 protected $cached_SERVER_NAME = null; 14 15 15 16 public function setUp() { … … 23 24 global $wpdb; 24 25 $wpdb->query( "TRUNCATE TABLE {$wpdb->users}" ); 26 27 // Fake WP mail globals, to avoid errors 28 add_filter( 'wp_mail', array( $this, 'setUp_wp_mail' ) ); 29 add_filter( 'wp_mail_from', array( $this, 'tearDown_wp_mail' ) ); 25 30 26 31 $this->factory = new BP_UnitTest_Factory; … … 305 310 * Set up globals necessary to avoid errors when using wp_mail() 306 311 */ 307 public function setUp_wp_mail() { 312 public function setUp_wp_mail( $args ) { 313 if ( isset( $_SERVER['SERVER_NAME'] ) ) { 314 $this->cached_SERVER_NAME = $_SERVER['SERVER_NAME']; 315 } 316 308 317 $_SERVER['SERVER_NAME'] = 'example.com'; 318 319 // passthrough 320 return $args; 309 321 } 310 322 … … 312 324 * Tear down globals set up in setUp_wp_mail() 313 325 */ 314 public function tearDown_wp_mail() { 315 unset( $_SERVER['SERVER_NAME'] ); 326 public function tearDown_wp_mail( $args ) { 327 if ( ! empty( $this->cached_SERVER_NAME ) ) { 328 $_SERVER['SERVER_NAME'] = $this->cached_SERVER_NAME; 329 unset( $this->cached_SERVER_NAME ); 330 } else { 331 unset( $_SERVER['SERVER_NAME'] ); 332 } 333 334 // passthrough 335 return $args; 316 336 } 317 337 }
Note: See TracChangeset
for help on using the changeset viewer.