Skip to:
Content

BuddyPress.org

Changeset 7039


Ignore:
Timestamp:
05/09/2013 01:19:50 PM (9 years ago)
Author:
boonebgorges
Message:

Use $this->set_current_user() instead of wp_set_current_user() throughout tests

Our custom method includes additional logic for busting BP-specific global data
that must be run in order for certain tests to pass reliably.

Location:
trunk/tests/testcases
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/activity/class.BP_Activity_Activity.php

    r6948 r7039  
    1010
    1111        $this->old_current_user = get_current_user_id();
    12         wp_set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
     12        $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
    1313    }
    1414
    1515    public function tearDown() {
    1616        parent::tearDown();
    17         wp_set_current_user( $this->old_current_user );
     17        $this->set_current_user( $this->old_current_user );
    1818    }
    1919
  • trunk/tests/testcases/activity/functions.php

    r6907 r7039  
    1010
    1111        $this->old_current_user = get_current_user_id();
    12         wp_set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
     12        $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
    1313    }
    1414
    1515    public function tearDown() {
    1616        parent::tearDown();
    17         wp_set_current_user( $this->old_current_user );
     17        $this->set_current_user( $this->old_current_user );
    1818    }
    1919
  • trunk/tests/testcases/admin/functions.php

    r6907 r7039  
    1010
    1111        $this->old_current_user = get_current_user_id();
    12         wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
     12        $this->set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
    1313
    1414        if ( ! function_exists( 'bp_admin' ) ) {
     
    2323    public function tearDown() {
    2424        parent::tearDown();
    25         wp_set_current_user( $this->old_current_user );
     25        $this->set_current_user( $this->old_current_user );
    2626    }
    2727
  • trunk/tests/testcases/core/class-bp-user-query.php

    r7024 r7039  
    1111
    1212        $this->old_current_user = get_current_user_id();
    13         wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
     13        $this->set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
    1414    }
    1515
    1616    public function tearDown() {
    1717        parent::tearDown();
    18         wp_set_current_user( $this->old_current_user );
     18        $this->set_current_user( $this->old_current_user );
    1919    }
    2020
  • trunk/tests/testcases/friends/class-bp-friends-friendship.php

    r7026 r7039  
    1111
    1212        $this->old_current_user = get_current_user_id();
    13         wp_set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
     13        $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
    1414    }
    1515
    1616    public function tearDown() {
    1717        parent::tearDown();
    18         wp_set_current_user( $this->old_current_user );
     18        $this->set_current_user( $this->old_current_user );
    1919    }
    2020
  • trunk/tests/testcases/members/template.php

    r6941 r7039  
    1010
    1111        $this->old_current_user = get_current_user_id();
    12         wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
     12        $new_user = $this->factory->user->create( array( 'role' => 'administrator' ) );
     13        $this->set_current_user( $new_user );
     14
    1315    }
    1416
    1517    public function tearDown() {
    1618        parent::tearDown();
    17         wp_set_current_user( $this->old_current_user );
     19        $this->set_current_user( $this->old_current_user );
    1820    }
    1921
  • trunk/tests/testcases/routing/activity.php

    r6907 r7039  
    1111
    1212        $this->old_current_user = get_current_user_id();
    13         wp_set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
     13        $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
    1414    }
    1515
    1616    public function tearDown() {
    1717        parent::tearDown();
    18         wp_set_current_user( $this->old_current_user );
     18        $this->set_current_user( $this->old_current_user );
    1919    }
    2020
  • trunk/tests/testcases/routing/core.php

    r6907 r7039  
    1111
    1212        $this->old_current_user = get_current_user_id();
    13         wp_set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
     13        $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
    1414    }
    1515
    1616    public function tearDown() {
    1717        parent::tearDown();
    18         wp_set_current_user( $this->old_current_user );
     18        $this->set_current_user( $this->old_current_user );
    1919    }
    2020
  • trunk/tests/testcases/routing/friends.php

    r6907 r7039  
    1111
    1212        $this->old_current_user = get_current_user_id();
    13         wp_set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
     13        $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
    1414    }
    1515
    1616    public function tearDown() {
    1717        parent::tearDown();
    18         wp_set_current_user( $this->old_current_user );
     18        $this->set_current_user( $this->old_current_user );
    1919    }
    2020
  • trunk/tests/testcases/routing/groups.php

    r6907 r7039  
    1111
    1212        $this->old_current_user = get_current_user_id();
    13         wp_set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
     13        $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
    1414    }
    1515
    1616    public function tearDown() {
    1717        parent::tearDown();
    18         wp_set_current_user( $this->old_current_user );
     18        $this->set_current_user( $this->old_current_user );
    1919    }
    2020
  • trunk/tests/testcases/routing/members.php

    r6907 r7039  
    1111
    1212        $this->old_current_user = get_current_user_id();
    13         wp_set_current_user( $this->factory->user->create( array( 'user_login' => 'paulgibbs', 'role' => 'subscriber' ) ) );
     13        $this->set_current_user( $this->factory->user->create( array( 'user_login' => 'paulgibbs', 'role' => 'subscriber' ) ) );
    1414    }
    1515
    1616    public function tearDown() {
    1717        parent::tearDown();
    18         wp_set_current_user( $this->old_current_user );
     18        $this->set_current_user( $this->old_current_user );
    1919    }
    2020
  • trunk/tests/testcases/routing/messages.php

    r6907 r7039  
    1111
    1212        $this->old_current_user = get_current_user_id();
    13         wp_set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
     13        $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
    1414    }
    1515
    1616    public function tearDown() {
    1717        parent::tearDown();
    18         wp_set_current_user( $this->old_current_user );
     18        $this->set_current_user( $this->old_current_user );
    1919    }
    2020
  • trunk/tests/testcases/routing/settings.php

    r6907 r7039  
    1111
    1212        $this->old_current_user = get_current_user_id();
    13         wp_set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
     13        $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
    1414    }
    1515
    1616    public function tearDown() {
    1717        parent::tearDown();
    18         wp_set_current_user( $this->old_current_user );
     18        $this->set_current_user( $this->old_current_user );
    1919    }
    2020
  • trunk/tests/testcases/routing/xprofile.php

    r6907 r7039  
    1111
    1212        $this->old_current_user = get_current_user_id();
    13         wp_set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
     13        $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
    1414    }
    1515
    1616    public function tearDown() {
    1717        parent::tearDown();
    18         wp_set_current_user( $this->old_current_user );
     18        $this->set_current_user( $this->old_current_user );
    1919    }
    2020
     
    3131    function test_member_profile_change_avatar() {
    3232        $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . buddypress()->profile->slug . '/change-avatar' );
    33         $this->assertTrue( bp_is_user_change_avatar() );   
     33        $this->assertTrue( bp_is_user_change_avatar() );
    3434    }
    3535}
  • trunk/tests/testcases/url/url.php

    r6907 r7039  
    1010
    1111        $this->old_current_user = get_current_user_id();
    12         wp_set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
     12        $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
    1313    }
    1414
    1515    public function tearDown() {
    1616        parent::tearDown();
    17         wp_set_current_user( $this->old_current_user );
     17        $this->set_current_user( $this->old_current_user );
    1818    }
    1919
Note: See TracChangeset for help on using the changeset viewer.