Changeset 7664
- Timestamp:
- 12/12/2013 08:43:28 PM (11 years ago)
- Location:
- trunk/tests
- Files:
-
- 4 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 } -
trunk/tests/testcases/friends/class-bp-friends-friendship.php
r7497 r7664 93 93 $u1 = $this->create_user(); 94 94 $u2 = $this->create_user(); 95 96 $this->setUp_wp_mail();97 95 friends_add_friend( $u1, $u2, false ); 98 $this->tearDown_wp_mail();99 100 96 $this->assertEquals( 'pending', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) ); 101 97 } … … 107 103 $u1 = $this->create_user(); 108 104 $u2 = $this->create_user(); 109 110 $this->setUp_wp_mail();111 105 friends_add_friend( $u1, $u2, false ); 112 $this->tearDown_wp_mail();113 114 106 $this->assertEquals( 'awaiting_response', BP_Friends_Friendship::check_is_friend( $u2, $u1 ) ); 115 107 } -
trunk/tests/testcases/groups/functions.php
r7500 r7664 227 227 $g = $this->factory->group->create( array( 'creator_id' => $u1 ) ); 228 228 229 $this->setUp_wp_mail();230 229 groups_send_membership_request( $u2, $g ); 231 230 groups_accept_membership_request( 0, $u2, $g ); 232 $this->tearDown_wp_mail();233 231 234 232 $this->assertEquals( 2, groups_get_groupmeta( $g, 'total_member_count' ) ); -
trunk/tests/testcases/members/template.php
r7497 r7664 45 45 $u2 = $this->create_user(); 46 46 47 $this->setUp_wp_mail();48 47 friends_add_friend( $u1, $u2 ); 49 $this->tearDown_wp_mail();50 48 51 49 $old_user = get_current_user_id();
Note: See TracChangeset
for help on using the changeset viewer.