Skip to:
Content

BuddyPress.org

Changeset 13980


Ignore:
Timestamp:
07/27/2024 04:30:23 PM (2 years ago)
Author:
espellcaste
Message:

Unit Tests: Conducted a thorough review of existing unit tests files and improved them to ensure robustness.

Props imath.

Closes https://github.com/buddypress/buddypress/pull/295
Fixes #9081

Location:
trunk/tests/phpunit
Files:
73 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/assets/group-extensions.php

    r10905 r13980  
    9494                return $this->setup_class_info();
    9595        }
    96 
    9796}
    9897
  • trunk/tests/phpunit/includes/factory.php

    r13874 r13980  
    22#[AllowDynamicProperties]
    33class BP_UnitTest_Factory extends WP_UnitTest_Factory {
    4         public $activity = null;
    5 
    6         function __construct() {
     4        public function __construct() {
    75                parent::__construct();
    86
    9                 $this->user = new BP_UnitTest_Factory_For_User( $this );
    10                 $this->activity = new BP_UnitTest_Factory_For_Activity( $this );
    11                 $this->group = new BP_UnitTest_Factory_For_Group( $this );
    12                 $this->message = new BP_UnitTest_Factory_For_Message( $this );
     7                $this->user           = new BP_UnitTest_Factory_For_User( $this );
     8                $this->activity       = new BP_UnitTest_Factory_For_Activity( $this );
     9                $this->group          = new BP_UnitTest_Factory_For_Group( $this );
     10                $this->message        = new BP_UnitTest_Factory_For_Message( $this );
    1311                $this->xprofile_group = new BP_UnitTest_Factory_For_XProfileGroup( $this );
    1412                $this->xprofile_field = new BP_UnitTest_Factory_For_XProfileField( $this );
    15                 $this->notification = new BP_UnitTest_Factory_For_Notification( $this );
    16                 $this->signup = new BP_UnitTest_Factory_For_Signup( $this );
    17                 $this->friendship = new BP_UnitTest_Factory_For_Friendship( $this );
     13                $this->notification   = new BP_UnitTest_Factory_For_Notification( $this );
     14                $this->signup         = new BP_UnitTest_Factory_For_Signup( $this );
     15                $this->friendship     = new BP_UnitTest_Factory_For_Friendship( $this );
    1816        }
    1917}
     
    5250class BP_UnitTest_Factory_For_Activity extends WP_UnitTest_Factory_For_Thing {
    5351
    54         function __construct( $factory = null ) {
     52        public function __construct( $factory = null ) {
    5553                parent::__construct( $factory );
    5654
     
    6462        }
    6563
    66         function create_object( $args ) {
    67                 if ( ! isset( $args['user_id'] ) )
     64        public function create_object( $args ) {
     65                if ( ! isset( $args['user_id'] ) ) {
    6866                        $args['user_id'] = get_current_user_id();
     67                }
    6968
    7069                return bp_activity_add( $args );
    7170        }
    7271
    73         function update_object( $activity_id, $fields ) {
     72        public function update_object( $activity_id, $fields ) {
    7473                $activity = new BP_Activity_Activity( $activity_id );
    7574
    7675                foreach ( $fields as $field_name => $value ) {
    77                         if ( isset( $activity->$field_name ) )
     76                        if ( isset( $activity->$field_name ) ) {
    7877                                $activity->$field_name = $value;
     78                        }
    7979                }
    8080
    8181                $activity->save();
     82
    8283                return $activity;
    8384        }
    8485
    85         function get_object_by_id( $user_id ) {
     86        public function get_object_by_id( $user_id ) {
    8687                return new BP_Activity_Activity( $user_id );
    8788        }
     
    9091class BP_UnitTest_Factory_For_Group extends WP_UnitTest_Factory_For_Thing {
    9192
    92         function __construct( $factory = null ) {
     93        public function __construct( $factory = null ) {
    9394                parent::__construct( $factory );
    9495
     
    104105        }
    105106
    106         function create_object( $args ) {
     107        public function create_object( $args ) {
    107108                if ( ! isset( $args['creator_id'] ) ) {
    108109                        if ( is_user_logged_in() ) {
     
    112113                        } else {
    113114                                $last_activity      = date( 'Y-m-d H:i:s', strtotime( bp_core_current_time() ) - 60 * 60 * 24 * 365 );
    114                                 $user_factory       = new WP_UnitTest_Factory_For_User();
    115115                                $args['creator_id'] = $this->factory->user->create( array( 'role' => 'subscriber' ) );
    116116
     
    138138        }
    139139
    140         function update_object( $group_id, $fields ) {
     140        public function update_object( $group_id, $fields ) {
    141141                $group = new BP_Groups_Group( $group_id );
    142142
    143143                foreach ( $fields as $field_name => $value ) {
    144                         if ( isset( $group->field_name ) )
     144                        if ( isset( $group->field_name ) ) {
    145145                                $group->field_name = $value;
     146                        }
    146147                }
    147148
    148149                $group->save();
     150
    149151                return $group;
    150152        }
    151153
    152         function get_object_by_id( $group_id ) {
     154        public function get_object_by_id( $group_id ) {
    153155                return new BP_Groups_Group( $group_id );
    154156        }
     
    157159class BP_UnitTest_Factory_For_Message extends WP_UnitTest_Factory_For_Thing {
    158160
    159         function __construct( $factory = null ) {
     161        public function __construct( $factory = null ) {
    160162                parent::__construct( $factory );
    161163
     
    169171        }
    170172
    171         function create_object( $args ) {
     173        public function create_object( $args ) {
    172174                if ( empty( $args['sender_id'] ) ) {
    173175                        $args['sender_id'] = $this->factory->user->create();
     
    185187        }
    186188
    187         function update_object( $message_id, $fields ) {
    188                 // todo
    189         }
    190 
    191         function get_object_by_id( $message_id ) {
     189        public function update_object( $message_id, $fields ) {}
     190
     191        public function get_object_by_id( $message_id ) {
    192192                return new BP_Messages_Message( $message_id );
    193193        }
     
    196196class BP_UnitTest_Factory_For_XProfileGroup extends WP_UnitTest_Factory_For_Thing {
    197197
    198         function __construct( $factory = null ) {
     198        public function __construct( $factory = null ) {
    199199                parent::__construct( $factory );
    200200
     
    206206        }
    207207
    208         function create_object( $args ) {
    209                 $group_id = xprofile_insert_field_group( $args );
    210                 return $group_id;
    211         }
    212 
    213         function update_object( $group_id, $fields ) {
    214         }
    215 
    216         function get_object_by_id( $group_id ) {
     208        public function create_object( $args ) {
     209                return xprofile_insert_field_group( $args );
     210        }
     211
     212        public function update_object( $group_id, $fields ) {}
     213
     214        public function get_object_by_id( $group_id ) {
    217215                return new BP_XProfile_Group( $group_id );
    218216        }
     
    221219class BP_UnitTest_Factory_For_XProfileField extends WP_UnitTest_Factory_For_Thing {
    222220
    223         function __construct( $factory = null ) {
     221        public function __construct( $factory = null ) {
    224222                parent::__construct( $factory );
    225223
     
    231229        }
    232230
    233         function create_object( $args ) {
    234                 $field_id = xprofile_insert_field( $args );
    235                 return $field_id;
    236         }
    237 
    238         function update_object( $field_id, $fields ) {
    239         }
    240 
    241         function get_object_by_id( $field_id ) {
     231        public function create_object( $args ) {
     232                return xprofile_insert_field( $args );
     233        }
     234
     235        public function update_object( $field_id, $fields ) {}
     236
     237        public function get_object_by_id( $field_id ) {
    242238                return new BP_XProfile_Field( $field_id );
    243239        }
     
    245241
    246242class BP_UnitTest_Factory_For_Notification extends WP_UnitTest_Factory_For_Thing {
    247         public function __construct( $factory = null ) {
    248                 parent::__construct( $factory );
    249         }
    250 
    251243        public function create_object( $args ) {
    252244                return bp_notifications_add_notification( $args );
     
    261253
    262254class BP_UnitTest_Factory_For_Signup extends WP_UnitTest_Factory_For_Thing {
    263         public function __construct( $factory = null ) {
    264                 parent::__construct( $factory );
    265         }
    266 
    267255        public function create_object( $args ) {
    268256                return BP_Signup::add( $args );
     
    282270 */
    283271class BP_UnitTest_Factory_For_Friendship extends WP_UnitTest_Factory_For_Thing {
    284         /**
    285          * Constructor.
    286          *
    287          * @since 2.7.0
    288          *
    289          * @param $factory WP_UnitTest_Factory
    290          */
    291         public function __construct( $factory = null ) {
    292                 parent::__construct( $factory );
    293         }
    294 
    295         /**
    296          * Create friendship object.
    297          *
    298          * @since 2.7.0
    299          *
    300          * @param array $args Array of arguments.
    301          * @return int Friendship ID.
    302          */
     272
    303273        public function create_object( $args ) {
    304274                $friendship = new BP_Friends_Friendship();
     
    323293        }
    324294
    325         /**
    326          * Update a friendship object.
    327          *
    328          * @since 2.7.0
    329          *
    330          * @todo Implement.
    331          *
    332          * @param int   $id     ID of the friendship.
    333          * @param array $fields Fields to update.
    334          */
    335295        public function update_object( $id, $fields ) {}
    336296
    337         /**
    338          * Get a friendship object by its ID.
    339          *
    340          * @since 2.7.0
    341          *
    342          * @param int $id
    343          * @return BP_Friends_Friendship
    344          */
    345297        public function get_object_by_id( $id ) {
    346298                return new BP_Friends_Friendship( $id );
  • trunk/tests/phpunit/includes/mock-mailer.php

    r10470 r13980  
    1111         * Send email(s).
    1212         *
     13         * @since 2.5.0
     14         *
    1315         * @param BP_Email $email Email to send.
    14          * @return bool False if some error occurred.
    15          * @since 2.5.0
     16         * @return bool
    1617         */
    1718        public function bp_email( BP_Email $email ) {
  • trunk/tests/phpunit/includes/testcase-emails.php

    r13314 r13980  
    1515                bp_core_install_emails();
    1616        }
    17 
    18         public static function tear_down_after_class() {
    19                 $emails = get_posts( array(
    20                         'fields'           => 'ids',
    21                         'post_status'      => 'any',
    22                         'post_type'        => bp_get_email_post_type(),
    23                         'posts_per_page'   => 200,
    24                         'suppress_filters' => false,
    25                 ) );
    26 
    27                 if ( $emails ) {
    28                         foreach ( $emails as $email_id ) {
    29                                 wp_delete_post( $email_id, true );
    30                         }
    31                 }
    32 
    33                 parent::tear_down_after_class();
    34         }
    3517}
  • trunk/tests/phpunit/includes/testcase.php

    r13468 r13980  
    11<?php
    22
    3 require_once dirname( __FILE__ ) . '/factory.php';
     3require_once __DIR__ . '/factory.php';
    44
    55class BP_UnitTestCase extends WP_UnitTestCase {
    66
     7        /**
     8         * Temp storage for users who have the bp_moderate capability.
     9         *
     10         * @var array
     11         */
    712        protected $temp_has_bp_moderate = array();
     13
     14        /**
     15         * A cached copy of the SERVER_NAME global.
     16         *
     17         * @var string
     18         */
    819        protected static $cached_SERVER_NAME = null;
    920
     
    3243         */
    3344        public static function set_up_before_class() {
    34                 global $wpdb;
    35 
    3645                // Fake WP mail globals, to avoid errors
    3746                add_filter( 'wp_mail', array( 'BP_UnitTestCase', 'setUp_wp_mail' ) );
    3847                add_filter( 'wp_mail_from', array( 'BP_UnitTestCase', 'tearDown_wp_mail' ) );
    3948
    40                 $c = self::get_called_class();
     49                $c = get_called_class();
     50
    4151                if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) {
    4252                        self::commit_transaction();
     
    5868                bp_core_add_page_mappings( bp_get_option( 'bp-active-components' ), 'delete' );
    5969
    60 
    61                 $this->factory = new BP_UnitTest_Factory;
     70                $this->factory = self::factory();
    6271
    6372                // Fixes warnings in multisite functions
    6473                $_SERVER['REMOTE_ADDR'] = '';
    65                 global $wpdb;
    6674
    6775                // Clean up after autocommits.
     
    112120         *
    113121         * @since 3.0.0
     122         *
     123         * @param int $user_id User ID.
     124         * @return bool True on success, false on failure.
    114125         */
    115126        public static function delete_user( $user_id ) {
     
    127138
    128139        public function clean_up_global_scope() {
    129                 buddypress()->bp_nav                = buddypress()->bp_options_nav = buddypress()->action_variables = buddypress()->canonical_stack = buddypress()->unfiltered_uri = $GLOBALS['bp_unfiltered_uri'] = array();
    130                 buddypress()->current_component     = buddypress()->current_item = buddypress()->current_action = buddypress()->current_member_type = '';
    131                 buddypress()->unfiltered_uri_offset = 0;
    132                 buddypress()->is_single_item        = false;
    133                 buddypress()->current_user          = new stdClass();
    134                 buddypress()->displayed_user        = new stdClass();
    135                 buddypress()->loggedin_user         = new stdClass();
    136                 buddypress()->pages                 = array();
    137                 buddypress()->groups->types         = array();
     140                $bp = buddypress();
     141
     142                $GLOBALS['bp_unfiltered_uri'] = array();
     143
     144                $bp->bp_nav                = array();
     145                $bp->bp_options_nav        = array();
     146                $bp->action_variables      = array();
     147                $bp->canonical_stack       = array();
     148                $bp->unfiltered_uri        = array();
     149                $bp->current_component     = '';
     150                $bp->current_item          = '';
     151                $bp->current_action        = '';
     152                $bp->current_member_type   = '';
     153                $bp->unfiltered_uri_offset = 0;
     154                $bp->is_single_item        = false;
     155                $bp->current_user          = new stdClass();
     156                $bp->displayed_user        = new stdClass();
     157                $bp->loggedin_user         = new stdClass();
     158                $bp->pages                 = array();
     159                $bp->groups->types         = array();
    138160
    139161                parent::clean_up_global_scope();
     
    191213
    192214        public function go_to( $url ) {
    193                 $GLOBALS['bp']->loggedin_user = NULL;
    194                 $GLOBALS['bp']->pages = bp_core_get_directory_pages();
     215                $GLOBALS['bp']->loggedin_user = null;
     216                $GLOBALS['bp']->pages         = bp_core_get_directory_pages();
    195217
    196218                foreach ( array_keys( bp_core_get_active_components() ) as $component ) {
    197219                        $GLOBALS['bp']->{$component}->main_nav = array();
    198                         $GLOBALS['bp']->{$component}->sub_nav = array();
     220                        $GLOBALS['bp']->{$component}->sub_nav  = array();
    199221                }
    200222
     
    221243                $bp = buddypress();
    222244
    223                 $bp->loggedin_user->id = $user_id;
     245                $bp->loggedin_user->id             = $user_id;
    224246                $bp->loggedin_user->fullname       = bp_core_get_user_displayname( $user_id );
    225                 $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( $user_id );
     247                $bp->loggedin_user->is_super_admin = is_super_admin( $user_id );
    226248                $bp->loggedin_user->domain         = bp_members_get_user_url( $user_id );
    227249                $bp->loggedin_user->userdata       = bp_core_get_core_userdata( $user_id );
     
    231253
    232254        public static function add_user_to_group( $user_id, $group_id, $args = array() ) {
    233                 $r = bp_parse_args( $args, array(
    234                         'date_modified' => bp_core_current_time(),
    235                         'is_confirmed'  => 1,
    236                         'is_admin'      => 0,
    237                         'is_mod'        => 0,
    238                         'invite_sent'   => 0,
    239                         'inviter_id'    => 0,
    240                 ) );
    241 
    242                 $new_member                = new BP_Groups_Member;
     255                $r = bp_parse_args(
     256                        $args,
     257                        array(
     258                                'date_modified' => bp_core_current_time(),
     259                                'is_confirmed'  => 1,
     260                                'is_admin'      => 0,
     261                                'is_mod'        => 0,
     262                                'invite_sent'   => 0,
     263                                'inviter_id'    => 0,
     264                        )
     265                );
     266
     267                $new_member                = new BP_Groups_Member();
    243268                $new_member->group_id      = $group_id;
    244269                $new_member->user_id       = $user_id;
    245                 $new_member->inviter_id    = 0;
    246270                $new_member->is_admin      = $r['is_admin'];
    247271                $new_member->is_mod        = $r['is_mod'];
     
    253277
    254278                $new_member->save();
     279
    255280                return $new_member->id;
    256281        }
     
    267292                }
    268293
    269                 $user = get_userdata( $user_id );
     294                $user           = get_userdata( $user_id );
    270295                $super_admins[] = $user->user_login;
    271296        }
     
    332357        public static function tearDown_wp_mail( $args ) {
    333358                if ( ! empty( self::$cached_SERVER_NAME ) ) {
    334                         $_SERVER['SERVER_NAME'] = self::$cached_SERVER_NAME;
     359                        $_SERVER['SERVER_NAME']   = self::$cached_SERVER_NAME;
    335360                        self::$cached_SERVER_NAME = '';
    336361                } else {
     
    348373                global $wpdb;
    349374                $wpdb->query( 'COMMIT;' );
     375        }
     376
     377        /**
     378         * Set a flag that an autocommit has taken place inside of a test method.
     379         *
     380         * @since 2.4.0
     381         */
     382        public function set_autocommit_flag() {
     383                $this->autocommitted = true;
     384        }
     385
     386        /**
     387         * Deactivate a component for the duration of a test.
     388         *
     389         * @since 2.4.0
     390         *
     391         * @param string $component Component name.
     392         */
     393        public function deactivate_component( $component ) {
     394                if ( ! isset( $component ) ) {
     395                        return;
     396                }
     397
     398                unset( buddypress()->active_components[ $component ] );
     399
     400                $this->deactivated_components[] = $component;
    350401        }
    351402
     
    375426
    376427        /**
    377          * Set a flag that an autocommit has taken place inside of a test method.
    378          *
    379          * @since 2.4.0
    380          */
    381         public function set_autocommit_flag() {
    382                 $this->autocommitted = true;
    383         }
    384 
    385         /**
    386          * Deactivate a component for the duration of a test.
    387          *
    388          * @since 2.4.0
    389          *
    390          * @param string $component Component name.
    391          */
    392         public function deactivate_component( $component ) {
    393                 $is_active = isset( buddypress()->active_components[ $component ] );
    394 
    395                 if ( ! isset( $component ) ) {
    396                         return false;
    397                 }
    398 
    399                 unset( buddypress()->active_components[ $component ] );
    400                 $this->deactivated_components[] = $component;
    401         }
    402 
    403         /**
    404428         * Fake an attachment upload (doesn't actually upload a file).
    405429         *
    406430         * @param string $file Absolute path to valid file.
    407          * @param int $parent Optional. Post ID to attach the new post to.
     431         * @param int    $parent Optional. Post ID to attach the new post to.
    408432         * @return int Attachment post ID.
    409433         */
     
    416440                }
    417441
    418                 $url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . basename( $file );
     442                $url        = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . basename( $file );
    419443                $attachment = array(
    420444                        'guid'           => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $url,
  • trunk/tests/phpunit/testcases/activity/filters.php

    r13433 r13980  
    5757                $this->assertEquals( $at_name_in_mailto_final, bp_activity_at_name_filter( $at_name_in_mailto ) );
    5858        }
    59 
    6059}
  • trunk/tests/phpunit/testcases/activity/functions.php

    r13636 r13980  
    14161416                // bp_activity_add_user_favorite() requires a logged-in user.
    14171417                $current_user = bp_loggedin_user_id();
    1418                 $this->set_current_user( $u );
     1418                self::set_current_user( $u );
    14191419
    14201420                $this->assertTrue( bp_activity_add_user_favorite( $a, $u ) );
     
    14241424                $this->assertEquals( 1, bp_activity_get_meta( $a, 'favorite_count' ) );
    14251425
    1426                 $this->set_current_user( $current_user );
     1426                self::set_current_user( $current_user );
    14271427        }
    14281428
     
    14371437                // bp_activity_add_user_favorite() requires a logged-in user.
    14381438                $current_user = bp_loggedin_user_id();
    1439                 $this->set_current_user( $u );
     1439                self::set_current_user( $u );
    14401440                $this->assertTrue( bp_activity_add_user_favorite( $a, $u ) );
    14411441
    1442                 $this->set_current_user( $current_user );
     1442                self::set_current_user( $current_user );
    14431443        }
    14441444
     
    14541454                // bp_activity_add_user_favorite() requires a logged-in user.
    14551455                $current_user = bp_loggedin_user_id();
    1456                 $this->set_current_user( $u1 );
     1456                self::set_current_user( $u1 );
    14571457
    14581458                // Only favorite for user 1
     
    14631463                $this->assertEquals( 1, bp_activity_get_meta( $a, 'favorite_count' ) );
    14641464
    1465                 $this->set_current_user( $current_user );
     1465                self::set_current_user( $current_user );
    14661466        }
    14671467
     
    14761476                // bp_activity_add_user_favorite() requires a logged-in user.
    14771477                $current_user = bp_loggedin_user_id();
    1478                 $this->set_current_user( $u1 );
     1478                self::set_current_user( $u1 );
    14791479
    14801480                // Only favorite for user 1
     
    14901490                $this->assertEquals( 1, bp_activity_get_meta( $a, 'favorite_count' ) );
    14911491
    1492                 $this->set_current_user( $current_user );
     1492                self::set_current_user( $current_user );
    14931493        }
    14941494
     
    16211621                $this->assertTrue( bp_activity_user_can_read( $o, $u ) );
    16221622
    1623                 $this->set_current_user( $u2 );
     1623                self::set_current_user( $u2 );
    16241624                $this->assertTrue( bp_activity_user_can_read( $o, $u2 ) );
    16251625        }
     
    16591659                bp_activity_mark_as_spam( $o );
    16601660
    1661                 $this->set_current_user( $u2 );
     1661                self::set_current_user( $u2 );
    16621662                $this->assertTrue( bp_activity_user_can_read( $o, $u2 ) );
    16631663        }
  • trunk/tests/phpunit/testcases/activity/functions/bpActivityGetActions.php

    r13314 r13980  
    2121
    2222        public function tear_down() {
    23                 parent::tear_down();
    2423                $bp = buddypress();
    2524
     
    3130                        unset( $bp->activity->actions_sorted );
    3231                }
     32                parent::tear_down();
    3333        }
    3434
  • trunk/tests/phpunit/testcases/activity/notifications.php

    r13468 r13980  
    2020                $this->u1 = self::factory()->user->create();
    2121                $this->u2 = self::factory()->user->create();
    22                 $this->set_current_user( $this->u1 );
     22                self::set_current_user( $this->u1 );
    2323
    2424                /**
     
    3232
    3333        public function tear_down() {
    34                 $this->set_current_user( $this->current_user );
     34                self::set_current_user( $this->current_user );
    3535                $this->set_permalink_structure( $this->permalink_structure );
    36 
    37                 parent::tear_down();
    3836
    3937                // Restore the filter
    4038                add_filter( 'bp_activity_at_name_do_notifications', '__return_false' );
     39
     40                parent::tear_down();
    4141        }
    4242
     
    9090
    9191                // Log out
    92                 $this->set_current_user( 0 );
     92                self::set_current_user( 0 );
    9393
    9494                // Go to the activity permalink page
     
    110110                $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) );
    111111
    112                 $this->set_current_user( $this->u1 );
     112                self::set_current_user( $this->u1 );
    113113        }
    114114
     
    129129
    130130                // Switch user
    131                 $this->set_current_user( $this->u2 );
     131                self::set_current_user( $this->u2 );
    132132
    133133                // Go to the activity permalink page
     
    149149                $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) );
    150150
    151                 $this->set_current_user( $this->u1 );
     151                self::set_current_user( $this->u1 );
    152152        }
    153153
     
    202202
    203203                // Log out
    204                 $this->set_current_user( 0 );
     204                self::set_current_user( 0 );
    205205
    206206                // Go to the My Activity page
     
    223223
    224224                // clean up
    225                 $this->set_current_user( $this->u1 );
     225                self::set_current_user( $this->u1 );
    226226        }
    227227
     
    242242
    243243                // Log out
    244                 $this->set_current_user( $this->u2 );
     244                self::set_current_user( $this->u2 );
    245245
    246246                // Go to the My Activity page
     
    263263
    264264                // clean up
    265                 $this->set_current_user( $this->u1 );
     265                self::set_current_user( $this->u1 );
    266266        }
    267267
     
    444444
    445445                // Attempt to mark 'comment_reply' notifications as read for user 2.
    446                 $this->set_current_user( $this->u2 );
     446                self::set_current_user( $this->u2 );
    447447                foreach ( $u2_notifications as $i => $n ) {
    448448                        $n = bp_activity_format_notifications( $n->component_action, $n->item_id, $n->secondary_item_id, 1, 'array', $n->id );
     
    471471                $u3 = self::factory()->user->create();
    472472
    473                 $this->set_current_user( $u1 );
     473                self::set_current_user( $u1 );
    474474                $userdata = get_userdata( $u1 );
    475475
     
    487487                ) );
    488488
    489                 $this->set_current_user( $u2 );
     489                self::set_current_user( $u2 );
    490490                $userdata = get_userdata( $u2 );
    491491
     
    503503                self::factory()->comment->update_object( $c1, array( 'comment_approved' => 1 ) );
    504504
    505                 $this->set_current_user( $u3 );
     505                self::set_current_user( $u3 );
    506506                $userdata = get_userdata( $u3 );
    507507
     
    543543
    544544                // Reset.
    545                 $this->set_current_user( $old_user );
     545                self::set_current_user( $old_user );
    546546                remove_filter( 'bp_disable_blogforum_comments', '__return_false' );
    547547                remove_filter( 'comment_flood_filter', '__return_false' );
    548548        }
    549 
    550549}
  • trunk/tests/phpunit/testcases/activity/template.php

    r11737 r13980  
    1212                $u = self::factory()->user->create();
    1313                $original_user = bp_loggedin_user_id();
    14                 $this->set_current_user( $u );
     14                self::set_current_user( $u );
    1515
    1616                $a = self::factory()->activity->create( array(
     
    2424
    2525                // Logged-out user can't delete
    26                 $this->set_current_user( 0 );
     26                self::set_current_user( 0 );
    2727                $this->assertFalse( bp_activity_user_can_delete( $activity ) );
    2828
    2929                // Miscellaneous user can't delete
    3030                $misc_user = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    31                 $this->set_current_user( $misc_user );
     31                self::set_current_user( $misc_user );
    3232                $this->assertFalse( bp_activity_user_can_delete( $activity ) );
    3333
     
    4343                $bp->is_single_item = $is_single_item;
    4444                $bp->is_item_admin = $is_item_admin;
    45                 $this->set_current_user( $original_user );
     45                self::set_current_user( $original_user );
    4646        }
    4747
     
    5353                $old_user = get_current_user_id();
    5454                $u = self::factory()->user->create();
    55                 $this->set_current_user( $u );
     55                self::set_current_user( $u );
    5656
    5757                // create an activity update for the user
     
    7070
    7171                // reset
    72                 $this->set_current_user( $old_user );
     72                self::set_current_user( $old_user );
    7373        }
    7474
     
    9696
    9797                $current_user = bp_loggedin_user_id();
    98                 $this->set_current_user( $user_id );
     98                self::set_current_user( $user_id );
    9999
    100100                bp_activity_add_user_favorite( $a1, $user_id );
    101101                bp_activity_add_user_favorite( $a2, $user_id );
    102102
    103                 $this->set_current_user( $current_user );
     103                self::set_current_user( $current_user );
    104104
    105105                // groan. It sucks that you have to invoke the global
     
    146146                // save the current user and override logged-in user
    147147                $old_user = get_current_user_id();
    148                 $this->set_current_user( $u1 );
     148                self::set_current_user( $u1 );
    149149
    150150                $now = time();
     
    188188                // clean up!
    189189                $activities_template = null;
    190                 $this->set_current_user( $old_user );
     190                self::set_current_user( $old_user );
    191191        }
    192192
     
    10071007                $u3 = self::factory()->user->create();
    10081008
    1009                 $this->set_current_user( $u1 );
     1009                self::set_current_user( $u1 );
    10101010
    10111011                $g = self::factory()->group->create( array(
     
    10611061                $u3 = self::factory()->user->create();
    10621062
    1063                 $this->set_current_user( $u1 );
     1063                self::set_current_user( $u1 );
    10641064
    10651065                $g = self::factory()->group->create( array(
  • trunk/tests/phpunit/testcases/admin/functions.php

    r13777 r13980  
    99                parent::set_up();
    1010                $this->old_current_user = get_current_user_id();
    11                 $this->set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     11                self::set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    1212
    1313                if ( ! function_exists( 'bp_admin' ) ) {
     
    2121
    2222        public function tear_down() {
     23                self::set_current_user( $this->old_current_user );
    2324                parent::tear_down();
    24                 $this->set_current_user( $this->old_current_user );
    2525        }
    2626
  • trunk/tests/phpunit/testcases/blogs/activity.php

    r13642 r13980  
    300300                $old_user = get_current_user_id();
    301301                $u = self::factory()->user->create();
    302                 $this->set_current_user( $u );
     302                self::set_current_user( $u );
    303303                $userdata = get_userdata( $u );
    304304
     
    338338                remove_filter( 'bp_disable_blogforum_comments', '__return_false' );
    339339
    340                 $this->set_current_user( $old_user );
     340                self::set_current_user( $old_user );
    341341        }
    342342
     
    348348                $old_user = get_current_user_id();
    349349                $u = self::factory()->user->create();
    350                 $this->set_current_user( $u );
     350                self::set_current_user( $u );
    351351                $userdata = get_userdata( $u );
    352352
     
    386386                remove_filter( 'bp_disable_blogforum_comments', '__return_false' );
    387387
    388                 $this->set_current_user( $old_user );
     388                self::set_current_user( $old_user );
    389389        }
    390390
     
    396396                $old_user = get_current_user_id();
    397397                $u = self::factory()->user->create();
    398                 $this->set_current_user( $u );
     398                self::set_current_user( $u );
    399399                $userdata = get_userdata( $u );
    400400
     
    446446                remove_filter( 'bp_disable_blogforum_comments', '__return_false' );
    447447
    448                 $this->set_current_user( $old_user );
     448                self::set_current_user( $old_user );
    449449        }
    450450
     
    456456                $old_user = get_current_user_id();
    457457                $u = self::factory()->user->create();
    458                 $this->set_current_user( $u );
     458                self::set_current_user( $u );
    459459                $userdata = get_userdata( $u );
    460460
     
    503503                remove_filter( 'bp_disable_blogforum_comments', '__return_false' );
    504504
    505                 $this->set_current_user( $old_user );
     505                self::set_current_user( $old_user );
    506506        }
    507507
     
    513513                $old_user = get_current_user_id();
    514514                $u = self::factory()->user->create();
    515                 $this->set_current_user( $u );
     515                self::set_current_user( $u );
    516516                $userdata = get_userdata( $u );
    517517
     
    560560                remove_filter( 'bp_disable_blogforum_comments', '__return_false' );
    561561
    562                 $this->set_current_user( $old_user );
     562                self::set_current_user( $old_user );
    563563        }
    564564
     
    570570                $old_user = get_current_user_id();
    571571                $u = self::factory()->user->create();
    572                 $this->set_current_user( $u );
     572                self::set_current_user( $u );
    573573                $userdata = get_userdata( $u );
    574574
     
    614614                remove_action( 'bp_activity_before_save', array( $this, 'set_activity_to_spam' ) );
    615615
    616                 $this->set_current_user( $old_user );
     616                self::set_current_user( $old_user );
    617617        }
    618618
     
    626626                $reset_at = isset( $GLOBALS['activities_template'] ) ? $GLOBALS['activities_template'] : null;
    627627
    628                 $this->set_current_user( $u );
     628                self::set_current_user( $u );
    629629
    630630                // let's use activity comments instead of single "new_blog_comment" activity items
     
    673673                remove_filter( 'bp_disable_blogforum_comments', '__return_false' );
    674674                $GLOBALS['activities_template'] = $reset_at;
    675                 $this->set_current_user( $old_user );
     675                self::set_current_user( $old_user );
    676676        }
    677677
     
    685685                $reset_at = isset( $GLOBALS['activities_template'] ) ? $GLOBALS['activities_template'] : null;
    686686
    687                 $this->set_current_user( $u );
     687                self::set_current_user( $u );
    688688
    689689                // let's use activity comments instead of single "new_blog_comment" activity items
     
    731731                remove_filter( 'bp_disable_blogforum_comments', '__return_false' );
    732732                $GLOBALS['activities_template'] = $reset_at;
    733                 $this->set_current_user( $old_user );
     733                self::set_current_user( $old_user );
    734734        }
    735735
  • trunk/tests/phpunit/testcases/blogs/cache.php

    r12606 r13980  
    9999                // Switch user so we have access to non-public blogs
    100100                $old_user = get_current_user_id();
    101                 $this->set_current_user( $u );
     101                self::set_current_user( $u );
    102102
    103103                $b1 = self::factory()->blog->create();
     
    177177                }
    178178
    179                 $this->set_current_user( $old_user );
     179                self::set_current_user( $old_user );
    180180        }
    181181
     
    193193                // Switch user so we have access to non-public blogs
    194194                $old_user = get_current_user_id();
    195                 $this->set_current_user( $u );
     195                self::set_current_user( $u );
    196196
    197197                $b1 = self::factory()->blog->create();
     
    230230                $this->assertFalse( wp_cache_get( $b2, 'bp_blog_meta' ) );
    231231
    232                 $this->set_current_user( $old_user );
     232                self::set_current_user( $old_user );
    233233        }
    234234
  • trunk/tests/phpunit/testcases/blogs/class-bp-blogs-blog.php

    r13184 r13980  
    1414
    1515                $u = self::factory()->user->create();
    16                 $this->set_current_user( $u );
     16                self::set_current_user( $u );
    1717                $b = self::factory()->blog->create( array(
    1818                        'title' => 'The Foo Bar Blog',
     
    4444
    4545                $u = self::factory()->user->create();
    46                 $this->set_current_user( $u );
     46                self::set_current_user( $u );
    4747                $b = self::factory()->blog->create( array(
    4848                        'title' => 'The Foo Bar Blog',
     
    7474
    7575                $u = self::factory()->user->create();
    76                 $this->set_current_user( $u );
     76                self::set_current_user( $u );
    7777                $b = self::factory()->blog->create( array(
    7878                        'title' => 'The Foo Bar Blog',
     
    103103
    104104                $u = self::factory()->user->create();
    105                 $this->set_current_user( $u );
     105                self::set_current_user( $u );
    106106                $b = self::factory()->blog->create( array(
    107107                        'title' => 'Foo Bar Blog',
     
    131131
    132132                $u = self::factory()->user->create();
    133                 $this->set_current_user( $u );
     133                self::set_current_user( $u );
    134134                $bs = array(
    135135                        'foobar' => self::factory()->blog->create( array(
     
    176176                $this->assertTrue( 2 == count( $blogs['blogs'] ) );
    177177
    178                 $this->set_current_user( $old_user );
     178                self::set_current_user( $old_user );
    179179        }
    180180
     
    189189                $old_user = get_current_user_id();
    190190                $u = self::factory()->user->create();
    191                 $this->set_current_user( $u );
     191                self::set_current_user( $u );
    192192
    193193                $r = [
     
    230230                $old_user = get_current_user_id();
    231231                $u = self::factory()->user->create();
    232                 $this->set_current_user( $u );
     232                self::set_current_user( $u );
    233233
    234234                $r = [
     
    273273                $old_user = get_current_user_id();
    274274                $u = self::factory()->user->create();
    275                 $this->set_current_user( $u );
     275                self::set_current_user( $u );
    276276
    277277                $r = [
  • trunk/tests/phpunit/testcases/blogs/filters.php

    r13314 r13980  
    2424
    2525        function tear_down() {
    26                 parent::tear_down();
    27 
    28                 $bp = buddypress();
    29 
    3026                _unregister_post_type( 'using_old_filter' );
    3127                remove_filter( 'bp_blogs_record_post_post_types',    array( $this, 'filter_post_types' ), 10 );
    3228                remove_filter( 'bp_blogs_record_comment_post_types', array( $this, 'filter_post_types' ), 10 );
     29
     30                parent::tear_down();
    3331        }
    3432
  • trunk/tests/phpunit/testcases/blogs/functions.php

    r13414 r13980  
    521521                $old_user = get_current_user_id();
    522522                $u = self::factory()->user->create();
    523                 $this->set_current_user( $u );
     523                self::set_current_user( $u );
    524524                $userdata = get_userdata( $u );
    525525
     
    594594
    595595                // reset
    596                 $this->set_current_user( $old_user );
     596                self::set_current_user( $old_user );
    597597        }
    598598
     
    606606                $old_user = get_current_user_id();
    607607                $u = self::factory()->user->create();
    608                 $this->set_current_user( $u );
     608                self::set_current_user( $u );
    609609                $userdata = get_userdata( $u );
    610610
     
    657657
    658658                // reset
    659                 $this->set_current_user( $old_user );
     659                self::set_current_user( $old_user );
    660660                remove_filter( 'bp_disable_blogforum_comments', '__return_false' );
    661661        }
     
    668668                $old_user = get_current_user_id();
    669669                $u = self::factory()->user->create();
    670                 $this->set_current_user( $u );
     670                self::set_current_user( $u );
    671671                $userdata = get_userdata( $u );
    672672
     
    766766                $old_user = get_current_user_id();
    767767                $u = self::factory()->user->create();
    768                 $this->set_current_user( $u );
     768                self::set_current_user( $u );
    769769                $userdata = get_userdata( $u );
    770770                $this->activity_saved_comment_count = 0;
     
    819819                $this->activity_saved_comment_count = 0;
    820820                $this->comment_saved_count = 0;
    821                 $this->set_current_user( $old_user );
     821                self::set_current_user( $old_user );
    822822        }
    823823
     
    830830                $old_user = get_current_user_id();
    831831                $u = self::factory()->user->create();
    832                 $this->set_current_user( $u );
     832                self::set_current_user( $u );
    833833
    834834                // Get user details
     
    879879                $this->assertNotNull( $a1, 'Activity item was not created for existing blog post when recording post comment.' );
    880880
    881                 $this->set_current_user( $old_user );
     881                self::set_current_user( $old_user );
    882882        }
    883883
     
    10051005
    10061006                $u = self::factory()->user->create();
    1007                 $this->set_current_user( $u );
     1007                self::set_current_user( $u );
    10081008
    10091009                // Create three sites.
     
    10231023                $this->assertSame( 3, (int) $blogs['total'] );
    10241024
    1025                 $this->set_current_user( $old_user );
     1025                self::set_current_user( $old_user );
    10261026        }
    10271027
     
    10411041
    10421042                $u = self::factory()->user->create();
    1043                 $this->set_current_user( $u );
     1043                self::set_current_user( $u );
    10441044
    10451045                // Create three sites.
     
    10701070
    10711071                $_POST = $reset_post;
    1072                 $this->set_current_user( $old_user );
     1072                self::set_current_user( $old_user );
    10731073        }
    10741074
     
    10881088
    10891089                $u = self::factory()->user->create();
    1090                 $this->set_current_user( $u );
     1090                self::set_current_user( $u );
    10911091
    10921092                // Create three sites.
     
    11171117
    11181118                $_POST = $reset_post;
    1119                 $this->set_current_user( $old_user );
     1119                self::set_current_user( $old_user );
    11201120        }
    11211121
  • trunk/tests/phpunit/testcases/core/avatars.php

    r13417 r13980  
    99        protected $allowed_image_mimes = array( 'image/jpeg', 'image/jpeg', 'image/jpeg', 'image/gif', 'image/png', 'image/webp' );
    1010
    11         public function set_up() {
    12                 parent::set_up();
    13         }
    14 
    1511        private function clean_existing_avatars( $type = 'user' ) {
    1612                if ( 'user' === $type ) {
    1713                        $avatar_dir = 'avatars';
    18                 } elseif ( 'group' === $object ) {
     14                } elseif ( 'group' === $type ) {
    1915                        $avatar_dir = 'group-avatars';
    2016                }
  • trunk/tests/phpunit/testcases/core/caps.php

    r13314 r13980  
    2020
    2121        public function tear_down() {
     22                self::set_current_user( $this->reset_user_id );
    2223                parent::tear_down();
    23 
    24                 $this->set_current_user( $this->reset_user_id );
    2524        }
    2625
     
    3332                $u = self::factory()->user->create();
    3433
    35                 $this->set_current_user( $u );
     34                self::set_current_user( $u );
    3635
    3736                add_filter( 'user_has_cap', array( $this, 'grant_cap_foo' ), 10, 2 );
     
    5554                $u = self::factory()->user->create();
    5655
    57                 $this->set_current_user( $u );
     56                self::set_current_user( $u );
    5857
    5958                add_filter( 'user_has_cap', array( $this, 'grant_cap_foo' ), 10, 2 );
     
    8988                );
    9089
    91                 $this->set_current_user( $u );
     90                self::set_current_user( $u );
    9291
    9392                $this->assertTrue( bp_current_user_can( 'bp_moderate' ), 'Administrator can `bp_moderate` on default WordPress config' );
     
    109108                );
    110109
    111                 $this->set_current_user( $u );
     110                self::set_current_user( $u );
    112111
    113112                $this->assertTrue( bp_current_user_can( 'bp_moderate' ), 'Users having a `manage_options` cap into their role can `bp_moderate`' );
     
    131130                );
    132131
    133                 $this->set_current_user( $u1 );
     132                self::set_current_user( $u1 );
    134133
    135134                $email = self::factory()->post->create(
     
    141140                $this->assertTrue( current_user_can( 'edit_post', $email ), 'Administrator should be able to edit emails they created' );
    142141
    143                 $this->set_current_user( $u2 );
     142                self::set_current_user( $u2 );
    144143
    145144                $this->assertTrue( current_user_can( 'edit_post', $email ), 'Administrator should be able to edit emails others created when BuddyPress is not network activated' );
     
    172171                switch_to_blog( $this->blog_id );
    173172
    174                 $this->set_current_user( $u1 );
     173                self::set_current_user( $u1 );
    175174                $this->assertTrue( bp_current_user_can( 'bp_moderate' ), 'Only Super Admins can `bp_moderate` when BuddyPress is network activated' );
    176175
    177                 $this->set_current_user( $u2 );
     176                self::set_current_user( $u2 );
    178177
    179178                $this->assertFalse( bp_current_user_can( 'bp_moderate' ), 'Regular Admins cannot `bp_moderate` when BuddyPress is network activated' );
     
    220219                restore_current_blog();
    221220
    222                 $this->set_current_user( $u1 );
     221                self::set_current_user( $u1 );
    223222                $this->assertTrue( current_user_can( 'edit_post', $email ), 'Super Admins should be able to edit emails they created' );
    224223
    225                 $this->set_current_user( $u2 );
     224                self::set_current_user( $u2 );
    226225                $this->assertFalse( current_user_can( 'edit_post', $email ), 'Administrator should not be able to edit emails others created when BuddyPress is network activated' );
    227226
  • trunk/tests/phpunit/testcases/core/class-bp-attachment.php

    r13414 r13980  
    2323
    2424        public function tear_down() {
    25                 parent::tear_down();
    2625                remove_filter( 'bp_attachment_upload_overrides',     array( $this, 'filter_overrides' ),       10 );
    2726                remove_filter( 'upload_dir',                         array( $this, 'filter_upload_dir' ),      20 );
     
    3029                $this->image_file = '';
    3130                $this->original_upload_dir = array();
     31                parent::tear_down();
    3232        }
    3333
  • trunk/tests/phpunit/testcases/core/class-bp-button.php

    r13433 r13980  
    2424        public function test_block_self_own_profile() {
    2525                $u = self::factory()->user->create();
    26                 $this->set_current_user( $u );
     26                self::set_current_user( $u );
    2727                $this->set_permalink_structure( '/%postname%/' );
    2828
     
    4343        public function test_block_self_others_profile() {
    4444                $u1 = self::factory()->user->create();
    45                 $this->set_current_user( $u1 );
     45                self::set_current_user( $u1 );
    4646                $this->set_permalink_structure( '/%postname%/' );
    4747
     
    7070                ) );
    7171
    72                 $this->set_current_user( $u1 );
     72                self::set_current_user( $u1 );
    7373
    7474                $found = array();
     
    110110                ) );
    111111
    112                 $this->set_current_user( $u1 );
     112                self::set_current_user( $u1 );
    113113
    114114                $found = array();
     
    150150                ) );
    151151
    152                 $this->set_current_user( $u1 );
     152                self::set_current_user( $u1 );
    153153                $this->set_permalink_structure( '/%postname%/' );
    154154                $this->go_to( bp_members_get_user_url( $u1 ) );
  • trunk/tests/phpunit/testcases/core/class-bp-email.php

    r13905 r13980  
    300300
    301301        public function test_sending_email() {
    302                 require_once( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-admin-schema.php' );
    303                 bp_core_install_emails();
    304 
    305                 $user1  = get_user_by( 'id', $this->u1 );
    306302                $result = bp_send_email( 'activity-comment', $this->u1, array(
    307303                        'tokens' => array(
     
    343339                $this->assertSame( $name, $email->get_subject( 'replace-tokens' ) );
    344340        }
    345 
    346341}
  • trunk/tests/phpunit/testcases/core/class-bp-user-query.php

    r13878 r13980  
    101101
    102102                $old_user = get_current_user_id();
    103                 $this->set_current_user( $u1 );
     103                self::set_current_user( $u1 );
    104104
    105105                // pass 'user_ids' to user query to trigger this bug
     
    112112
    113113                // clean up
    114                 $this->set_current_user( $old_user );
     114                self::set_current_user( $old_user );
    115115        }
    116116
     
    862862                $this->assertEquals( $u1, $query->user_ids[0] );
    863863        }
    864 
    865864}
  • trunk/tests/phpunit/testcases/core/class-bp-walker-nav-menu.php

    r13442 r13980  
    1414
    1515                $this->user_id = self::factory()->user->create();
    16                 $this->set_current_user( $this->user_id );
     16                self::set_current_user( $this->user_id );
    1717        }
    1818
    1919        public function tear_down() {
     20                self::set_current_user( $this->reset_user_id );
    2021                parent::tear_down();
    21                 $this->set_current_user( $this->reset_user_id );
    2222        }
    2323
  • trunk/tests/phpunit/testcases/core/community-visibility.php

    r13533 r13980  
    1111                $this->old_user = get_current_user_id();
    1212                $this->logged_in_user = self::factory()->user->create();
    13                 $this->set_current_user( $this->logged_in_user );
     13                self::set_current_user( $this->logged_in_user );
    1414
    1515                // Save a typical setting.
     
    2121
    2222        public function tear_down() {
    23                 parent::tear_down();
    24                 $this->set_current_user( $this->old_user );
     23                self::set_current_user( $this->old_user );
    2524                // Reset site to totally open.
    2625                delete_option( '_bp_community_visibility' );
     26                parent::tear_down();
    2727        }
    2828
  • trunk/tests/phpunit/testcases/core/functions/bpCoreGetDirectoryPageId.php

    r13436 r13980  
    1515
    1616        public function tear_down() {
     17                $this->set_permalink_structure( $this->permalink_structure );
    1718                parent::tear_down();
    18                 $this->set_permalink_structure( $this->permalink_structure );
    1919        }
    2020
  • trunk/tests/phpunit/testcases/core/invitations.php

    r13082 r13980  
    1111                $old_current_user = get_current_user_id();
    1212
    13                 $u1 = $this->factory->user->create();
    14                 $u2 = $this->factory->user->create();
    15                 $u3 = $this->factory->user->create();
    16                 $this->set_current_user( $u1 );
     13                $u1 = self::factory()->user->create();
     14                $u2 = self::factory()->user->create();
     15                $u3 = self::factory()->user->create();
     16                self::set_current_user( $u1 );
    1717
    1818                $invites_class = new BPTest_Invitation_Manager_Extension();
     
    3636                $this->assertEqualSets( array( $i1, $i2 ), $invites );
    3737
    38                 $this->set_current_user( $old_current_user );
     38                self::set_current_user( $old_current_user );
    3939        }
    4040
     
    4242                $old_current_user = get_current_user_id();
    4343
    44                 $u1 = $this->factory->user->create();
    45                 $u2 = $this->factory->user->create();
    46                 $this->set_current_user( $u1 );
     44                $u1 = self::factory()->user->create();
     45                $u2 = self::factory()->user->create();
     46                self::set_current_user( $u1 );
    4747
    4848                $invites_class = new BPTest_Invitation_Manager_Extension();
     
    6060                $this->assertEquals( $i1, $i2 );
    6161
    62                 $this->set_current_user( $old_current_user );
     62                self::set_current_user( $old_current_user );
    6363        }
    6464
     
    6666                $old_current_user = get_current_user_id();
    6767
    68                 $u1 = $this->factory->user->create();
    69                 $u2 = $this->factory->user->create();
    70                 $u3 = $this->factory->user->create();
    71                 $this->set_current_user( $u1 );
     68                $u1 = self::factory()->user->create();
     69                $u2 = self::factory()->user->create();
     70                $u3 = self::factory()->user->create();
     71                self::set_current_user( $u1 );
    7272
    7373                $invites_class = new BPTest_Invitation_Manager_Extension();
     
    9696                $this->assertEqualSets( array( $i1 ), wp_list_pluck( $invites, 'id' ) );
    9797
    98                 $this->set_current_user( $old_current_user );
     98                self::set_current_user( $old_current_user );
    9999        }
    100100
     
    102102                $old_current_user = get_current_user_id();
    103103
    104                 $u1 = $this->factory->user->create();
    105                 $u2 = $this->factory->user->create();
    106                 $u3 = $this->factory->user->create();
    107                 $this->set_current_user( $u1 );
     104                $u1 = self::factory()->user->create();
     105                $u2 = self::factory()->user->create();
     106                $u3 = self::factory()->user->create();
     107                self::set_current_user( $u1 );
    108108
    109109                $invites_class = new BPTest_Invitation_Manager_Extension();
     
    132132                $this->assertEqualSets( array(), wp_list_pluck( $invites, 'id' ) );
    133133
    134                 $this->set_current_user( $old_current_user );
     134                self::set_current_user( $old_current_user );
    135135        }
    136136
     
    138138                $old_current_user = get_current_user_id();
    139139
    140                 $u1 = $this->factory->user->create();
    141                 $u2 = $this->factory->user->create();
    142                 $u3 = $this->factory->user->create();
    143                 $this->set_current_user( $u1 );
     140                $u1 = self::factory()->user->create();
     141                $u2 = self::factory()->user->create();
     142                $u3 = self::factory()->user->create();
     143                self::set_current_user( $u1 );
    144144
    145145                $invites_class = new BPTest_Invitation_Manager_Extension();
     
    173173                $this->assertEqualSets( array( $i1, $r1 ), $invites );
    174174
    175                 $this->set_current_user( $old_current_user );
     175                self::set_current_user( $old_current_user );
    176176        }
    177177
     
    179179                $old_current_user = get_current_user_id();
    180180
    181                 $u1 = $this->factory->user->create();
    182                 $this->set_current_user( $u1 );
     181                $u1 = self::factory()->user->create();
     182                self::set_current_user( $u1 );
    183183
    184184                $invites_class = new BPTest_Invitation_Manager_Extension();
     
    200200                $this->assertEqualSets( array( $r1, $r2 ), $requests );
    201201
    202                 $this->set_current_user( $old_current_user );
     202                self::set_current_user( $old_current_user );
    203203        }
    204204
     
    208208                $invites_class = new BPTest_Invitation_Manager_Extension();
    209209
    210                 $u1 = $this->factory->user->create();
    211                 $this->set_current_user( $u1 );
     210                $u1 = self::factory()->user->create();
     211                self::set_current_user( $u1 );
    212212
    213213                // Create a couple of requests.
     
    220220                $this->assertFalse( $invites_class->add_request( $request_args ) );
    221221
    222                 $this->set_current_user( $old_current_user );
     222                self::set_current_user( $old_current_user );
    223223        }
    224224
     
    226226                $old_current_user = get_current_user_id();
    227227
    228                 $u1 = $this->factory->user->create();
    229                 $u2 = $this->factory->user->create();
    230                 $this->set_current_user( $u1 );
     228                $u1 = self::factory()->user->create();
     229                $u2 = self::factory()->user->create();
     230                self::set_current_user( $u1 );
    231231
    232232                $invites_class = new BPTest_Invitation_Manager_Extension();
     
    258258                $this->assertEqualSets( array( $r1, $i1 ), $invites );
    259259
    260                 $this->set_current_user( $old_current_user );
     260                self::set_current_user( $old_current_user );
    261261        }
    262262
     
    264264                $old_current_user = get_current_user_id();
    265265
    266                 $u1 = $this->factory->user->create();
    267                 $u2 = $this->factory->user->create();
    268                 $this->set_current_user( $u1 );
     266                $u1 = self::factory()->user->create();
     267                $u2 = self::factory()->user->create();
     268                self::set_current_user( $u1 );
    269269
    270270                $invites_class = new BPTest_Invitation_Manager_Extension();
     
    286286                $this->assertEquals( 1, $invite->invite_sent );
    287287
    288                 $this->set_current_user( $old_current_user );
     288                self::set_current_user( $old_current_user );
    289289        }
    290290
     
    292292                $old_current_user = get_current_user_id();
    293293
    294                 $u1 = $this->factory->user->create();
    295                 $u2 = $this->factory->user->create();
    296                 $this->set_current_user( $u1 );
     294                $u1 = self::factory()->user->create();
     295                $u2 = self::factory()->user->create();
     296                self::set_current_user( $u1 );
    297297
    298298                $invites_class = new BPTest_Invitation_Manager_Extension();
     
    331331                $this->assertEqualSets( array( $i2 ), $invites );
    332332
    333                 $this->set_current_user( $old_current_user );
     333                self::set_current_user( $old_current_user );
    334334        }
    335335
     
    337337                $old_current_user = get_current_user_id();
    338338
    339                 $u1 = $this->factory->user->create();
    340                 $this->set_current_user( $u1 );
     339                $u1 = self::factory()->user->create();
     340                self::set_current_user( $u1 );
    341341
    342342                $invites_class = new BPTest_Invitation_Manager_Extension();
     
    353353                $this->assertEquals( $time, $req->date_modified );
    354354
    355                 $this->set_current_user( $old_current_user );
     355                self::set_current_user( $old_current_user );
    356356        }
    357357
     
    359359                $old_current_user = get_current_user_id();
    360360
    361                 $u1 = $this->factory->user->create();
    362                 $u2 = $this->factory->user->create();
    363                 $this->set_current_user( $u1 );
     361                $u1 = self::factory()->user->create();
     362                $u2 = self::factory()->user->create();
     363                self::set_current_user( $u1 );
    364364
    365365                $invites_class = new BPTest_Invitation_Manager_Extension();
     
    379379                $this->assertEquals( $time, $inv->date_modified );
    380380
    381                 $this->set_current_user( $old_current_user );
     381                self::set_current_user( $old_current_user );
    382382        }
    383383
     
    385385                $old_current_user = get_current_user_id();
    386386
    387                 $u1 = $this->factory->user->create();
    388                 $u2 = $this->factory->user->create();
    389                 $u3 = $this->factory->user->create();
    390                 $this->set_current_user( $u1 );
     387                $u1 = self::factory()->user->create();
     388                $u2 = self::factory()->user->create();
     389                $u3 = self::factory()->user->create();
     390                self::set_current_user( $u1 );
    391391
    392392                $invites_class = new BPTest_Invitation_Manager_Extension();
     
    429429                $this->assertEquals( array( $i3, $i1, $i2 ), $invites );
    430430
    431                 $this->set_current_user( $old_current_user );
     431                self::set_current_user( $old_current_user );
    432432        }
    433433}
  • trunk/tests/phpunit/testcases/core/nav/bpCoreMaybeHookNewSubnavScreenFunction.php

    r13437 r13980  
    4949        public function test_user_has_access_false_user_logged_out() {
    5050                $old_current_user = get_current_user_id();
    51                 $this->set_current_user( 0 );
     51                self::set_current_user( 0 );
    5252
    5353                $subnav_item = array(
     
    6262                $this->assertSame( $expected, bp_core_maybe_hook_new_subnav_screen_function( $subnav_item ) );
    6363
    64                 $this->set_current_user( $old_current_user );
     64                self::set_current_user( $old_current_user );
    6565        }
    6666
     
    6868                $u = self::factory()->user->create();
    6969                $old_current_user = get_current_user_id();
    70                 $this->set_current_user( $u );
     70                self::set_current_user( $u );
    7171                $this->set_permalink_structure( '/%postname%/' );
    7272
     
    8282                $this->assertSame( bp_members_get_user_url( $u ), $found['redirect_args']['root'] );
    8383
    84                 $this->set_current_user( $old_current_user );
     84                self::set_current_user( $old_current_user );
    8585        }
    8686
     
    8989                $u2 = self::factory()->user->create();
    9090                $old_current_user = get_current_user_id();
    91                 $this->set_current_user( $u1 );
     91                self::set_current_user( $u1 );
    9292                $this->set_permalink_structure( '/%postname%/' );
    9393
     
    113113
    114114                // Clean up
    115                 $this->set_current_user( $old_current_user );
     115                self::set_current_user( $old_current_user );
    116116                buddypress()->default_component = $old_default_component;
    117117                buddypress()->bp_nav = $old_bp_nav;
     
    125125                $u2 = self::factory()->user->create();
    126126                $old_current_user = get_current_user_id();
    127                 $this->set_current_user( $u1 );
     127                self::set_current_user( $u1 );
    128128                $this->set_permalink_structure( '/%postname%/' );
    129129
     
    150150
    151151                // Clean up
    152                 $this->set_current_user( $old_current_user );
     152                self::set_current_user( $old_current_user );
    153153                buddypress()->default_component = $old_default_component;
    154154                buddypress()->bp_nav = $old_bp_nav;
     
    170170                $g = self::factory()->group->create();
    171171                $old_current_user = get_current_user_id();
    172                 $this->set_current_user( $u );
     172                self::set_current_user( $u );
    173173                $this->set_permalink_structure( '/%postname%/' );
    174174
     
    188188
    189189                // Clean up
    190                 $this->set_current_user( $old_current_user );
     190                self::set_current_user( $old_current_user );
    191191        }
    192192
     
    195195                $g = self::factory()->group->create();
    196196                $old_current_user = get_current_user_id();
    197                 $this->set_current_user( $u );
     197                self::set_current_user( $u );
    198198
    199199                $group = groups_get_group( $g );
     
    211211
    212212                // Clean up
    213                 $this->set_current_user( $old_current_user );
     213                self::set_current_user( $old_current_user );
    214214        }
    215215}
  • trunk/tests/phpunit/testcases/core/nav/bpCoreNewSubnavItem.php

    r13507 r13980  
    5050        public function test_site_admin_only() {
    5151                $old_current_user = get_current_user_id();
    52                 $this->set_current_user( 0 );
     52                self::set_current_user( 0 );
    5353
    5454                $this->assertFalse( bp_core_new_subnav_item( array(
     
    6161                ) ) );
    6262
    63                 $this->set_current_user( $old_current_user );
     63                self::set_current_user( $old_current_user );
    6464        }
    6565
     
    110110                $u = self::factory()->user->create();
    111111                $old_current_user = get_current_user_id();
    112                 $this->set_current_user( $u );
     112                self::set_current_user( $u );
    113113
    114114                $url = bp_members_get_user_url(
     
    128128                remove_action( 'bp_setup_nav', array( $this, 'new_nav_hook' ), 0 );
    129129
    130                 $this->set_current_user( $old_current_user );
     130                self::set_current_user( $old_current_user );
    131131        }
    132132}
  • trunk/tests/phpunit/testcases/core/nav/bpGetNavMenuItems.php

    r13433 r13980  
    2525                $users = self::factory()->user->create_many( 2 );
    2626
    27                 $this->set_current_user( $users[0] );
     27                self::set_current_user( $users[0] );
    2828                $this->set_permalink_structure( '/%postname%/' );
    2929
     
    5151                $user = self::factory()->user->create();
    5252
    53                 $this->set_current_user( 0 );
     53                self::set_current_user( 0 );
    5454                $this->set_permalink_structure( '/%postname%/' );
    5555
  • trunk/tests/phpunit/testcases/core/optouts.php

    r12913 r13980  
    88                $old_current_user = get_current_user_id();
    99
    10                 $u1 = $this->factory->user->create();
    11                 $this->set_current_user( $u1 );
     10                $u1 = self::factory()->user->create();
     11                self::set_current_user( $u1 );
    1212
    1313                // Create a couple of optouts.
     
    2828                $this->assertEqualSets( array( $i1, $i2 ), $optouts );
    2929
    30                 $this->set_current_user( $old_current_user );
     30                self::set_current_user( $old_current_user );
    3131        }
    3232
     
    3434                $old_current_user = get_current_user_id();
    3535
    36                 $u1 = $this->factory->user->create();
    37                 $this->set_current_user( $u1 );
     36                $u1 = self::factory()->user->create();
     37                self::set_current_user( $u1 );
    3838
    3939                // Create an optouts.
     
    4848                $this->assertEquals( $i1, $i2 );
    4949
    50                 $this->set_current_user( $old_current_user );
     50                self::set_current_user( $old_current_user );
    5151        }
    5252
     
    5454                $old_current_user = get_current_user_id();
    5555
    56                 $u1 = $this->factory->user->create();
    57                 $this->set_current_user( $u1 );
     56                $u1 = self::factory()->user->create();
     57                self::set_current_user( $u1 );
    5858
    5959                $args = array(
     
    7272                $this->assertTrue( empty( $optouts ) );
    7373
    74                 $this->set_current_user( $old_current_user );
     74                self::set_current_user( $old_current_user );
    7575        }
    7676
     
    7878                $old_current_user = get_current_user_id();
    7979
    80                 $u1 = $this->factory->user->create();
    81                 $this->set_current_user( $u1 );
     80                $u1 = self::factory()->user->create();
     81                self::set_current_user( $u1 );
    8282
    8383                // Create a couple of optouts.
     
    9898                $this->assertEqualSets( array( $i1 ), $optouts );
    9999
    100                 $this->set_current_user( $old_current_user );
     100                self::set_current_user( $old_current_user );
    101101        }
    102102
     
    104104                $old_current_user = get_current_user_id();
    105105
    106                 $u1 = $this->factory->user->create();
    107                 $this->set_current_user( $u1 );
     106                $u1 = self::factory()->user->create();
     107                self::set_current_user( $u1 );
    108108
    109109                // Create a couple of optouts.
     
    124124                $this->assertEqualSets( array( $i1 ), $optouts );
    125125
    126                 $this->set_current_user( $old_current_user );
     126                self::set_current_user( $old_current_user );
    127127        }
    128128
     
    130130                $old_current_user = get_current_user_id();
    131131
    132                 $u1 = $this->factory->user->create();
    133                 $this->set_current_user( $u1 );
     132                $u1 = self::factory()->user->create();
     133                self::set_current_user( $u1 );
    134134
    135135                // Create a couple of optouts.
     
    150150                $this->assertEqualSets( array( $i1 ), $optouts );
    151151
    152                 $this->set_current_user( $old_current_user );
     152                self::set_current_user( $old_current_user );
    153153        }
    154154
     
    157157                $old_current_user = get_current_user_id();
    158158
    159                 $u1 = $this->factory->user->create();
    160                 $this->set_current_user( $u1 );
     159                $u1 = self::factory()->user->create();
     160                self::set_current_user( $u1 );
    161161
    162162                // Create an opt-out.
     
    179179                $this->assertEqualSets( array( $i1 ), $optouts );
    180180
    181                 $this->set_current_user( $old_current_user );
     181                self::set_current_user( $old_current_user );
    182182        }
    183183
     
    185185                $old_current_user = get_current_user_id();
    186186
    187                 $u1 = $this->factory->user->create();
    188                 $this->set_current_user( $u1 );
     187                $u1 = self::factory()->user->create();
     188                self::set_current_user( $u1 );
    189189                // Create an opt-out.
    190190                $args = array(
     
    199199
    200200                $this->assertTrue( is_wp_error( $email->validate() ) );
    201                 $this->set_current_user( $old_current_user );
    202         }
    203 
     201                self::set_current_user( $old_current_user );
     202        }
    204203}
  • trunk/tests/phpunit/testcases/core/suggestions.php

    r13314 r13980  
    112112        public function set_up() {
    113113                parent::set_up();
    114                 $this->set_current_user( self::$current_user );
     114                self::set_current_user( self::$current_user );
    115115        }
    116116
    117117        public function tear_down() {
     118                self::set_current_user( self::$old_user_id );
    118119                parent::tear_down();
    119                 $this->set_current_user( self::$old_user_id );
    120120        }
    121121
     
    269269
    270270                // "alpaca red" is in the hidden group
    271                 $this->set_current_user( self::$user_ids['alpaca red'] );
     271                self::set_current_user( self::$user_ids['alpaca red'] );
    272272                $suggestions = bp_core_get_suggestions( array(
    273273                        'group_id' => self::$group_ids['hidden'],
     
    289289
    290290                // "caterpillar" is in the private group
    291                 $this->set_current_user( self::$user_ids['caterpillar'] );
     291                self::set_current_user( self::$user_ids['caterpillar'] );
    292292                $suggestions = bp_core_get_suggestions( array(
    293293                        'group_id' => self::$group_ids['private'],
     
    328328
    329329
    330                 $this->set_current_user( self::$user_ids['caterpillar'] );
     330                self::set_current_user( self::$user_ids['caterpillar'] );
    331331
    332332                // "cat" is in the private group, so won't show up here.
     
    359359
    360360
    361                 $this->set_current_user( self::$user_ids['alpaca red'] );
     361                self::set_current_user( self::$user_ids['alpaca red'] );
    362362
    363363                // "alpaca red" is in the hidden group, so won't show up here.
  • trunk/tests/phpunit/testcases/core/template/bpUserHasAccess.php

    r13433 r13980  
    2222
    2323                $this->grant_bp_moderate( $users[0] );
    24                 $this->set_current_user( $users[0] );
     24                self::set_current_user( $users[0] );
    2525                $this->set_permalink_structure( '/%postname%/' );
    2626
     
    3333                $users = self::factory()->user->create_many( 2 );
    3434
    35                 $this->set_current_user( $users[0] );
     35                self::set_current_user( $users[0] );
    3636                $this->set_permalink_structure( '/%postname%/' );
    3737
     
    4444                $users = self::factory()->user->create_many( 2 );
    4545
    46                 $this->set_current_user( $users[0] );
     46                self::set_current_user( $users[0] );
    4747                $this->set_permalink_structure( '/%postname%/' );
    4848
  • trunk/tests/phpunit/testcases/friends/activity.php

    r12605 r13980  
    6363
    6464                // Set current user to u1 to accepte the friendship
    65                 $this->set_current_user( $u1 );
    66                 friends_accept_friendship( $friendship_id );
    67 
    68                 // Reset the current user
    69                 $this->set_current_user( $old_user );
     65                self::set_current_user( $u1 );
     66                friends_accept_friendship( $friendship_id );
     67
     68                // Reset the current user
     69                self::set_current_user( $old_user );
    7070
    7171                // Random activities
     
    110110
    111111                // Set current user to u1 to accept the friendship
    112                 $this->set_current_user( $u1 );
    113                 friends_accept_friendship( $friendship_id );
    114 
    115                 // Reset the current user
    116                 $this->set_current_user( $old_user );
     112                self::set_current_user( $u1 );
     113                friends_accept_friendship( $friendship_id );
     114
     115                // Reset the current user
     116                self::set_current_user( $old_user );
    117117
    118118                $u1_act = bp_activity_get( array(
     
    149149
    150150                // Set current user to u1 to accepte the friendship and generate a public activity
    151                 $this->set_current_user( $u1 );
    152                 friends_accept_friendship( $friendship_id );
    153 
    154                 // Reset the current user
    155                 $this->set_current_user( $old_user );
     151                self::set_current_user( $u1 );
     152                friends_accept_friendship( $friendship_id );
     153
     154                // Reset the current user
     155                self::set_current_user( $old_user );
    156156
    157157                $users[] = self::factory()->user->create();
     
    199199
    200200                // Set current user to u1 to accept the friendship
    201                 $this->set_current_user( $u1 );
    202                 friends_accept_friendship( $friendship_id );
    203 
    204                 // Reset the current user
    205                 $this->set_current_user( $old_user );
     201                self::set_current_user( $u1 );
     202                friends_accept_friendship( $friendship_id );
     203
     204                // Reset the current user
     205                self::set_current_user( $old_user );
    206206
    207207                // Delete $u1.
     
    223223                $old_user = get_current_user_id();
    224224                $u1 = self::factory()->user->create();
    225                 $this->set_current_user( $u1 );
     225                self::set_current_user( $u1 );
    226226
    227227                bp_activity_remove_all_user_data( $u1 );
     
    229229                wp_delete_user( $u1 );
    230230
    231                 $this->set_current_user( $old_user );
     231                self::set_current_user( $old_user );
    232232
    233233                // Remove the following lines when you implement this test.
  • trunk/tests/phpunit/testcases/friends/functions.php

    r13314 r13980  
    6767                // accept friendship
    6868                $old_user = get_current_user_id();
    69                 $this->set_current_user( $u1 );
     69                self::set_current_user( $u1 );
    7070                friends_accept_friendship( friends_get_friendship_id( $u2, $u1 ) );
    7171
     
    7474                $this->assertEquals( array( $u3 ), $requests );
    7575
    76                 $this->set_current_user( $old_user );
     76                self::set_current_user( $old_user );
    7777        }
    7878
     
    124124                // user 2 withdraws friendship
    125125                $old_user = get_current_user_id();
    126                 $this->set_current_user( $u2 );
     126                self::set_current_user( $u2 );
    127127                friends_withdraw_friendship( $u2, $u1 );
    128128
     
    131131                $this->assertEquals( array(), $requests );
    132132
    133                 $this->set_current_user( $old_user );
     133                self::set_current_user( $old_user );
    134134        }
    135135
     
    152152                // user 1 rejects friendship
    153153                $old_user = get_current_user_id();
    154                 $this->set_current_user( $u1 );
     154                self::set_current_user( $u1 );
    155155                friends_reject_friendship( friends_get_friendship_id( $u2, $u1 ) );
    156156
     
    159159                $this->assertEquals( array(), $requests );
    160160
    161                 $this->set_current_user( $old_user );
     161                self::set_current_user( $old_user );
    162162        }
    163163
     
    198198
    199199                $old_user = get_current_user_id();
    200                 $this->set_current_user( $u1 );
     200                self::set_current_user( $u1 );
    201201
    202202                $found = array();
     
    217217                // clean up
    218218                $GLOBALS['members_template'] = null;
    219                 $this->set_current_user( $old_user );
     219                self::set_current_user( $old_user );
    220220        }
    221221
     
    300300                 * @see bp_friends_filter_user_query_populate_extras()
    301301                 */
    302                 $this->set_current_user( $u1 );
     302                self::set_current_user( $u1 );
    303303                $this->go_to( bp_get_members_directory_permalink() );
    304304                ob_start();
     
    315315                 * properly.
    316316                 */
    317                 $this->set_current_user( $u2 );
     317                self::set_current_user( $u2 );
    318318                friends_accept_friendship( friends_get_friendship_id( $u1, $u2 ) );
    319319
    320320                // Afterwards, user 1 decides to cancel friendship.
    321                 $this->set_current_user( $u1 );
     321                self::set_current_user( $u1 );
    322322                friends_remove_friend( $u1, $u2 );
    323323
     
    325325                $this->assertEquals( 'not_friends', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
    326326
    327                 $this->set_current_user( $old_user );
     327                self::set_current_user( $old_user );
    328328        }
    329329
  • trunk/tests/phpunit/testcases/friends/notifications.php

    r13314 r13980  
    1212                parent::set_up();
    1313                $this->current_user = get_current_user_id();
    14                 $this->set_current_user( self::factory()->user->create() );
     14                self::set_current_user( self::factory()->user->create() );
    1515
    1616                $this->friend = self::factory()->user->create();
     
    1919
    2020        public function tear_down() {
     21                self::set_current_user( $this->current_user );
    2122                parent::tear_down();
    22                 $this->set_current_user( $this->current_user );
    2323        }
    2424
  • trunk/tests/phpunit/testcases/groups/activity.php

    r13870 r13980  
    105105                $old_user = get_current_user_id();
    106106                $u = self::factory()->user->create();
    107                 $this->set_current_user( $u );
     107                self::set_current_user( $u );
    108108
    109109                $group = self::factory()->group->create_and_get();
     
    127127                $this->assertSame( $expected, $a['activities'][0]->action );
    128128
    129                 $this->set_current_user( $old_user );
     129                self::set_current_user( $old_user );
    130130        }
    131131
     
    137137                $old_user = get_current_user_id();
    138138                $u = self::factory()->user->create();
    139                 $this->set_current_user( $u );
     139                self::set_current_user( $u );
    140140
    141141                $group = self::factory()->group->create_and_get();
     
    159159                $this->assertSame( $expected, $a['activities'][0]->action );
    160160
    161                 $this->set_current_user( $old_user );
     161                self::set_current_user( $old_user );
    162162        }
    163163
     
    169169                $old_user = get_current_user_id();
    170170                $u = self::factory()->user->create();
    171                 $this->set_current_user( $u );
     171                self::set_current_user( $u );
    172172
    173173                $group = self::factory()->group->create_and_get();
     
    192192                $this->assertSame( $expected, $a['activities'][0]->action );
    193193
    194                 $this->set_current_user( $old_user );
     194                self::set_current_user( $old_user );
    195195        }
    196196
     
    202202                $old_user = get_current_user_id();
    203203                $u = self::factory()->user->create();
    204                 $this->set_current_user( $u );
     204                self::set_current_user( $u );
    205205
    206206                $group = self::factory()->group->create_and_get();
     
    224224                $this->assertSame( $expected, $a['activities'][0]->action );
    225225
    226                 $this->set_current_user( $old_user );
     226                self::set_current_user( $old_user );
    227227        }
    228228
     
    325325                ) );
    326326
    327                 $this->set_current_user( $u1 );
     327                self::set_current_user( $u1 );
    328328                if ( bp_has_activities( array( 'in' => $a ) ) ) {
    329329                        while ( bp_activities() ) : bp_the_activity();
     
    333333                }
    334334
    335                 $this->set_current_user( $u2 );
     335                self::set_current_user( $u2 );
    336336                if ( bp_has_activities( array( 'in' => $a ) ) ) {
    337337                        while ( bp_activities() ) : bp_the_activity();
     
    341341                }
    342342
    343                 $this->set_current_user( $old_user );
     343                self::set_current_user( $old_user );
    344344        }
    345345
     
    363363                $original_user = bp_loggedin_user_id();
    364364
    365                 $this->set_current_user( $u1 );
     365                self::set_current_user( $u1 );
    366366
    367367                $g = self::factory()->group->create();
     
    395395
    396396                // User can delete his own activity.
    397                 $this->set_current_user( $u2 );
     397                self::set_current_user( $u2 );
    398398                $this->assertTrue( bp_activity_user_can_delete( $activity ) );
    399399
    400400                // Activity from site admins can't be deleted by non site admins.
    401                 $this->set_current_user( $u2 );
     401                self::set_current_user( $u2 );
    402402                $this->assertFalse( bp_activity_user_can_delete( $activity_b ) );
    403403
    404404                // Activity from site admins can be deleted by other site admins.
    405405                $site_admin = self::factory()->user->create( array( 'role' => 'administrator' ) );
    406                 $this->set_current_user( $site_admin );
     406                self::set_current_user( $site_admin );
    407407                $this->assertTrue( bp_activity_user_can_delete( $activity_b ) );
    408408
    409409                // Group creator can delete activity.
    410                 $this->set_current_user( $u1 );
     410                self::set_current_user( $u1 );
    411411                $this->assertTrue( bp_activity_user_can_delete( $activity ) );
    412412
    413413                // Logged-out user can't delete activity.
    414                 $this->set_current_user( 0 );
     414                self::set_current_user( 0 );
    415415                $this->assertFalse( bp_activity_user_can_delete( $activity ) );
    416416
    417417                // Misc user can't delete activity.
    418418                $misc_user = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    419                 $this->set_current_user( $misc_user );
     419                self::set_current_user( $misc_user );
    420420                $this->assertFalse( bp_activity_user_can_delete( $activity ) );
    421421
     
    423423                $misc_user_2 = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    424424                self::add_user_to_group( $misc_user_2, $g );
    425                 $this->set_current_user( $misc_user_2 );
     425                self::set_current_user( $misc_user_2 );
    426426                $this->assertFalse( bp_activity_user_can_delete( $activity ) );
    427427
     
    429429                $misc_user_3 = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    430430                self::add_user_to_group( $misc_user_3, $g, [ 'is_mod' => true ] );
    431                 $this->set_current_user( $misc_user_3 );
     431                self::set_current_user( $misc_user_3 );
    432432                $this->assertTrue( bp_activity_user_can_delete( $activity ) );
    433433
     
    435435                $misc_user_4 = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    436436                self::add_user_to_group( $misc_user_4, $g, [ 'is_admin' => true ] );
    437                 $this->set_current_user( $misc_user_4 );
     437                self::set_current_user( $misc_user_4 );
    438438                $this->assertTrue( bp_activity_user_can_delete( $activity ) );
    439439
    440                 $this->set_current_user( $original_user );
     440                self::set_current_user( $original_user );
    441441        }
    442442
     
    449449                $original_user = bp_loggedin_user_id();
    450450
    451                 $this->set_current_user( $u1 );
     451                self::set_current_user( $u1 );
    452452
    453453                $g  = self::factory()->group->create();
     
    486486                self::add_user_to_group( $u2, $g, [ 'is_admin' => true ] );
    487487
    488                 $this->set_current_user( $u2 );
     488                self::set_current_user( $u2 );
    489489                $this->assertFalse( bp_activity_user_can_delete( $activity ), 'Group Admins or Mods shouldn not be able to delete activities that are not attached to a group' );
    490490
     
    500500                $this->assertFalse( bp_activity_user_can_delete( $activity ), 'Group Admins or Mods should not be able to delete another group activities.' );
    501501
    502                 $this->set_current_user( $original_user );
     502                self::set_current_user( $original_user );
    503503        }
    504504}
  • trunk/tests/phpunit/testcases/groups/class-bp-group-extension.php

    r13507 r13980  
    1616
    1717        public function tear_down() {
     18                $this->set_permalink_structure( $this->permalink_structure );
    1819                parent::tear_down();
    19                 $this->set_permalink_structure( $this->permalink_structure );
    2020        }
    2121
     
    241241                $this->go_to( bp_get_group_url( $g_obj ) );
    242242
    243                 $this->set_current_user( 0 );
     243                self::set_current_user( 0 );
    244244
    245245                $e = new BPTest_Group_Extension_Inferred_Access_Settings_EnableNavItem_True();
     
    251251                $this->assertFalse( $e2->user_can_visit() );
    252252
    253                 $this->set_current_user( $old_current_user );
     253                self::set_current_user( $old_current_user );
    254254        }
    255255
     
    260260                $this->set_permalink_structure( '/%postname%/' );
    261261                $old_current_user = get_current_user_id();
    262                 $this->set_current_user( 0 );
     262                self::set_current_user( 0 );
    263263
    264264                $g = self::factory()->group->create( array(
     
    292292                $this->assertFalse( $e6->user_can_visit() );
    293293
    294                 $this->set_current_user( $old_current_user );
     294                self::set_current_user( $old_current_user );
    295295        }
    296296
     
    307307                $u = self::factory()->user->create();
    308308                $old_current_user = get_current_user_id();
    309                 $this->set_current_user( $u );
     309                self::set_current_user( $u );
    310310
    311311                $this->go_to( bp_get_group_url( $g_obj ) );
     
    335335                $this->assertFalse( $e6->user_can_visit() );
    336336
    337                 $this->set_current_user( $old_current_user );
     337                self::set_current_user( $old_current_user );
    338338        }
    339339
     
    350350                $u = self::factory()->user->create();
    351351                $old_current_user = get_current_user_id();
    352                 $this->set_current_user( $u );
     352                self::set_current_user( $u );
    353353
    354354                $this->add_user_to_group( $u, $g );
     
    380380                $this->assertFalse( $e6->user_can_visit() );
    381381
    382                 $this->set_current_user( $old_current_user );
     382                self::set_current_user( $old_current_user );
    383383        }
    384384
     
    395395                $u = self::factory()->user->create();
    396396                $old_current_user = get_current_user_id();
    397                 $this->set_current_user( $u );
     397                self::set_current_user( $u );
    398398
    399399                $m = $this->add_user_to_group( $u, $g );
     
    427427                $this->assertFalse( $e6->user_can_visit() );
    428428
    429                 $this->set_current_user( $old_current_user );
     429                self::set_current_user( $old_current_user );
    430430        }
    431431
     
    442442                $u = self::factory()->user->create();
    443443                $old_current_user = get_current_user_id();
    444                 $this->set_current_user( $u );
     444                self::set_current_user( $u );
    445445
    446446                $m = $this->add_user_to_group( $u, $g );
     
    474474                $this->assertFalse( $e6->user_can_visit() );
    475475
    476                 $this->set_current_user( $old_current_user );
     476                self::set_current_user( $old_current_user );
    477477        }
    478478
     
    488488
    489489                $old_current_user = get_current_user_id();
    490                 $this->set_current_user( 0 );
     490                self::set_current_user( 0 );
    491491
    492492                $this->go_to( bp_get_group_url( $g_obj ) );
     
    516516                $this->assertFalse( $e6->user_can_visit() );
    517517
    518                 $this->set_current_user( $old_current_user );
     518                self::set_current_user( $old_current_user );
    519519        }
    520520
     
    530530
    531531                $old_current_user = get_current_user_id();
    532                 $this->set_current_user( 0 );
     532                self::set_current_user( 0 );
    533533
    534534                $this->go_to( bp_get_group_url( $g_obj ) );
     
    558558                $this->assertFalse( $e6->user_can_see_nav_item() );
    559559
    560                 $this->set_current_user( $old_current_user );
     560                self::set_current_user( $old_current_user );
    561561        }
    562562
     
    573573                $u = self::factory()->user->create();
    574574                $old_current_user = get_current_user_id();
    575                 $this->set_current_user( $u );
     575                self::set_current_user( $u );
    576576
    577577                $this->go_to( bp_get_group_url( $g_obj ) );
     
    601601                $this->assertFalse( $e6->user_can_see_nav_item() );
    602602
    603                 $this->set_current_user( $old_current_user );
     603                self::set_current_user( $old_current_user );
    604604        }
    605605
     
    616616                $u = self::factory()->user->create();
    617617                $old_current_user = get_current_user_id();
    618                 $this->set_current_user( $u );
     618                self::set_current_user( $u );
    619619
    620620                $this->add_user_to_group( $u, $g );
     
    646646                $this->assertFalse( $e6->user_can_see_nav_item() );
    647647
    648                 $this->set_current_user( $old_current_user );
     648                self::set_current_user( $old_current_user );
    649649        }
    650650
     
    661661                $u = self::factory()->user->create();
    662662                $old_current_user = get_current_user_id();
    663                 $this->set_current_user( $u );
     663                self::set_current_user( $u );
    664664
    665665                $this->add_user_to_group( $u, $g );
     
    693693                $this->assertFalse( $e6->user_can_see_nav_item() );
    694694
    695                 $this->set_current_user( $old_current_user );
     695                self::set_current_user( $old_current_user );
    696696        }
    697697
     
    708708                $u = self::factory()->user->create();
    709709                $old_current_user = get_current_user_id();
    710                 $this->set_current_user( $u );
     710                self::set_current_user( $u );
    711711
    712712                $this->add_user_to_group( $u, $g );
     
    740740                $this->assertFalse( $e6->user_can_see_nav_item() );
    741741
    742                 $this->set_current_user( $old_current_user );
     742                self::set_current_user( $old_current_user );
    743743        }
    744744
  • trunk/tests/phpunit/testcases/groups/class-bp-groups-group.php

    r13414 r13980  
    976976
    977977                // Instantiate group object.
    978                 $this->set_current_user( $u );
     978                self::set_current_user( $u );
    979979                $group = new BP_Groups_Group( $g );
    980980
     
    982982                $this->assertTrue( ! empty( $group->is_member ) );
    983983
    984                 $this->set_current_user( $this->old_current_user );
     984                self::set_current_user( $this->old_current_user );
    985985        }
    986986
     
    14701470
    14711471                $old_user = get_current_user_id();
    1472                 $this->set_current_user( 0 );
     1472                self::set_current_user( 0 );
    14731473
    14741474                $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) );
    14751475
    1476                 $this->set_current_user( $old_user );
     1476                self::set_current_user( $old_user );
    14771477        }
    14781478
     
    15011501
    15021502                $old_user = get_current_user_id();
    1503                 $this->set_current_user( $u );
     1503                self::set_current_user( $u );
    15041504
    15051505                $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) );
    15061506
    1507                 $this->set_current_user( $old_user );
     1507                self::set_current_user( $old_user );
    15081508        }
    15091509
     
    15331533
    15341534                $old_user = get_current_user_id();
    1535                 $this->set_current_user( $u );
     1535                self::set_current_user( $u );
    15361536
    15371537                $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) );
    15381538
    1539                 $this->set_current_user( $old_user );
     1539                self::set_current_user( $old_user );
    15401540        }
    15411541
     
    15731573
    15741574                $old_user = get_current_user_id();
    1575                 $this->set_current_user( $u );
     1575                self::set_current_user( $u );
    15761576
    15771577                $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) );
    15781578
    1579                 $this->set_current_user( $old_user );
     1579                self::set_current_user( $old_user );
    15801580        }
    15811581
     
    16101610
    16111611                $old_user = get_current_user_id();
    1612                 $this->set_current_user( $u );
     1612                self::set_current_user( $u );
    16131613
    16141614                $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) );
    16151615
    1616                 $this->set_current_user( $old_user );
     1616                self::set_current_user( $old_user );
    16171617        }
    16181618
     
    16481648
    16491649                $old_user = get_current_user_id();
    1650                 $this->set_current_user( $u );
     1650                self::set_current_user( $u );
    16511651
    16521652                $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) );
    16531653
    1654                 $this->set_current_user( $old_user );
     1654                self::set_current_user( $old_user );
    16551655        }
    16561656
     
    24382438        public function test_get_return_ids_only() {
    24392439                $now = time();
    2440                 $g1 = $this->factory->group->create( array(
     2440                $g1 = self::factory()->group->create( array(
    24412441                        'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60 ),
    24422442                ) );
    2443                 $g2 = $this->factory->group->create( array(
     2443                $g2 = self::factory()->group->create( array(
    24442444                        'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60*2 ),
    24452445                ) );
    2446                 $g3 = $this->factory->group->create( array(
     2446                $g3 = self::factory()->group->create( array(
    24472447                        'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60*3 ),
    24482448                )  );
     
    24542454                $this->assertSame( array( $g1, $g2, $g3 ), $groups['groups'] );
    24552455        }
    2456 
    24572456}
    24582457
  • trunk/tests/phpunit/testcases/groups/class-bp-groups-member.php

    r13874 r13980  
    1515
    1616        public function tear_down() {
     17                $this->set_permalink_structure( $this->permalink_structure );
    1718                parent::tear_down();
    18                 $this->set_permalink_structure( $this->permalink_structure );
    1919        }
    2020
     
    222222                $this->assertTrue( bp_groups_user_can_send_invites( $g, $u_siteadmin ) );
    223223                // Falling back to current user
    224                 $this->set_current_user( $u_members );
     224                self::set_current_user( $u_members );
    225225                $this->assertTrue( bp_groups_user_can_send_invites( $g, null ) );
    226226
     
    233233                $this->assertTrue( bp_groups_user_can_send_invites( $g, $u_siteadmin ) );
    234234                // Falling back to current user
    235                 $this->set_current_user( $u_members );
     235                self::set_current_user( $u_members );
    236236                $this->assertFalse( bp_groups_user_can_send_invites( $g, null ) );
    237                 $this->set_current_user( $u_mods );
     237                self::set_current_user( $u_mods );
    238238                $this->assertTrue( bp_groups_user_can_send_invites( $g, null ) );
    239239
     
    246246                $this->assertTrue( bp_groups_user_can_send_invites( $g, $u_siteadmin ) );
    247247                // Falling back to current user
    248                 $this->set_current_user( $u_mods );
     248                self::set_current_user( $u_mods );
    249249                $this->assertFalse( bp_groups_user_can_send_invites( $g, null ) );
    250                 $this->set_current_user( $u_admins );
     250                self::set_current_user( $u_admins );
    251251                $this->assertTrue( bp_groups_user_can_send_invites( $g, null ) );
    252252
     
    264264                $this->assertTrue( bp_groups_user_can_send_invites( null, $u_mods ) );
    265265
    266                 $this->set_current_user( $old_current_user );
     266                self::set_current_user( $old_current_user );
    267267        }
    268268
     
    680680                $g = self::factory()->group->create();
    681681                $old_current_user = get_current_user_id();
    682                 $this->set_current_user( $u1 );
     682                self::set_current_user( $u1 );
    683683
    684684                groups_join_group( $g );
    685685                $membership_id = groups_is_user_member( $u1, $g );
    686686                $this->assertTrue( is_numeric( $membership_id ) && $membership_id > 0 );
    687                 $this->set_current_user( $old_current_user );
     687                self::set_current_user( $old_current_user );
    688688        }
    689689
     
    754754
    755755                $before = groups_get_total_member_count( $g );
    756                 $this->set_current_user( $u2 );
     756                self::set_current_user( $u2 );
    757757                groups_leave_group( $g, $u2 );
    758758                $after = groups_get_total_member_count( $g );
    759759
    760760                $this->assertEquals( $before - 1, $after );
    761                 $this->set_current_user( $old_current_user );
     761                self::set_current_user( $old_current_user );
    762762        }
    763763
     
    774774
    775775                $before = groups_get_total_member_count( $g );
    776                 $this->set_current_user( $u2 );
     776                self::set_current_user( $u2 );
    777777                groups_leave_group( $g );
    778778                $after = groups_get_total_member_count( $g );
    779779
    780780                $this->assertEquals( $before - 1, $after );
    781                 $this->set_current_user( $old_current_user );
     781                self::set_current_user( $old_current_user );
    782782        }
    783783
     
    794794
    795795                $before = groups_get_total_member_count( $g );
    796                 $this->set_current_user( $u1 );
     796                self::set_current_user( $u1 );
    797797                groups_leave_group( $g, $u2 );
    798798                $after = groups_get_total_member_count( $g );
    799799
    800800                $this->assertEquals( $before - 1, $after );
    801                 $this->set_current_user( $old_current_user );
     801                self::set_current_user( $old_current_user );
    802802        }
    803803
     
    816816
    817817                $before = groups_get_total_member_count( $g );
    818                 $this->set_current_user( $u1 );
     818                self::set_current_user( $u1 );
    819819                groups_leave_group( $g, $u2 );
    820820                $after = groups_get_total_member_count( $g );
    821821
    822822                $this->assertEquals( $before - 1, $after );
    823                 $this->set_current_user( $old_current_user );
     823                self::set_current_user( $old_current_user );
    824824        }
    825825
     
    836836
    837837                $before = groups_get_total_member_count( $g );
    838                 $this->set_current_user( $u1 );
     838                self::set_current_user( $u1 );
    839839                groups_leave_group( $g, $u1 );
    840840                $after = groups_get_total_member_count( $g );
    841841
    842842                $this->assertEquals( $before, $after );
    843                 $this->set_current_user( $old_current_user );
     843                self::set_current_user( $old_current_user );
    844844        }
    845845
     
    858858
    859859                $before = groups_get_total_member_count( $g );
    860                 $this->set_current_user( $u1 );
     860                self::set_current_user( $u1 );
    861861                groups_leave_group( $g, $u1 );
    862862                $after = groups_get_total_member_count( $g );
    863863
    864864                $this->assertEquals( $before - 1, $after );
    865                 $this->set_current_user( $old_current_user );
     865                self::set_current_user( $old_current_user );
    866866        }
    867867
     
    935935                ) );
    936936
    937                 $this->set_current_user( $u2 );
     937                self::set_current_user( $u2 );
    938938                $groups = groups_get_invites_for_user();
    939939                $this->assertEqualSets( array( $g1, $g2, $g3 ), wp_list_pluck( $groups['groups'], 'id' ) );
    940940
    941                 $this->set_current_user( $old_current_user );
     941                self::set_current_user( $old_current_user );
    942942        }
    943943
  • trunk/tests/phpunit/testcases/groups/functions.php

    r13357 r13980  
    6161
    6262                // Set the current user so the leave group request goes through.
    63                 $this->set_current_user( $u2 );
     63                self::set_current_user( $u2 );
    6464                groups_leave_group( $g1, $u2 );
    6565                $this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) );
     
    7979
    8080                // Fool the admin check
    81                 $this->set_current_user( $u1 );
     81                self::set_current_user( $u1 );
    8282                buddypress()->is_item_admin = true;
    8383
     
    100100
    101101                // Fool the admin check
    102                 $this->set_current_user( $u1 );
     102                self::set_current_user( $u1 );
    103103                buddypress()->is_item_admin = true;
    104104
     
    140140
    141141                $current_user = bp_loggedin_user_id();
    142                 $this->set_current_user( $u2 );
     142                self::set_current_user( $u2 );
    143143
    144144                $g = self::factory()->group->create( array( 'status' => 'private' ) );
     
    152152                $this->assertEquals( 1, bp_get_user_meta( $u1, 'total_group_count', true ) );
    153153
    154                 $this->set_current_user( $current_user );
     154                self::set_current_user( $current_user );
    155155        }
    156156
     
    168168
    169169                // Fool the admin check
    170                 $this->set_current_user( $u1 );
     170                self::set_current_user( $u1 );
    171171                buddypress()->is_item_admin = true;
    172172
     
    227227
    228228                // Fool the admin check
    229                 $this->set_current_user( $u1 );
     229                self::set_current_user( $u1 );
    230230                buddypress()->is_item_admin = true;
    231231
     
    248248
    249249                // Fool the admin check
    250                 $this->set_current_user( $u1 );
     250                self::set_current_user( $u1 );
    251251                buddypress()->is_item_admin = true;
    252252
     
    311311
    312312                // Fool the admin check
    313                 $this->set_current_user( $u1 );
     313                self::set_current_user( $u1 );
    314314                buddypress()->is_item_admin = true;
    315315
     
    382382                ) );
    383383
    384                 $this->set_current_user( $u1 );
     384                self::set_current_user( $u1 );
    385385                $g1 = self::factory()->group->create();
    386386
     
    389389                $this->assertEquals( 2, groups_get_total_member_count( $g1 ) );
    390390
    391                 $this->set_current_user( $current_user );
     391                self::set_current_user( $current_user );
    392392        }
    393393
  • trunk/tests/phpunit/testcases/groups/functions/get-group.php

    r13335 r13980  
    3636         */
    3737        public function test_bp_get_group_with_id() {
    38                 $g = $this->factory->group->create();
     38                $g = self::factory()->group->create();
    3939
    4040                $this->assertSame( $g, bp_get_group( $g )->id );
     
    4848        public function test_bp_get_group_with_slug() {
    4949                $slug = 'test-group';
    50                 $g    = $this->factory->group->create( array( 'slug' => $slug ) );
     50                $g    = self::factory()->group->create( array( 'slug' => $slug ) );
    5151                $g1   = bp_get_group( $slug );
    5252
     
    6464         */
    6565        public function test_bp_get_group_with_object() {
    66                 $g = $this->factory->group->create_and_get();
     66                $g = self::factory()->group->create_and_get();
    6767
    6868                $this->assertSame( $g->id, bp_get_group( $g )->id );
     
    7373         */
    7474        public function test_bp_get_group_from_groups_template() {
    75                 $g = $this->factory->group->create( array( 'status' => 'private' ) );
     75                $g = self::factory()->group->create( array( 'status' => 'private' ) );
    7676
    7777                if ( bp_has_groups( array( 'include' => array( $g ) ) ) ) {
     
    9090        public function test_bp_get_group_from_current_group() {
    9191                $bp = buddypress();
    92                 $g  = $this->factory->group->create_and_get( array( 'name' => 'foo' ) );
     92                $g  = self::factory()->group->create_and_get( array( 'name' => 'foo' ) );
    9393
    9494                // Set the current group.
  • trunk/tests/phpunit/testcases/groups/functions/groupsCreateGroup.php

    r11739 r13980  
    2222        public function test_should_respect_creator_id() {
    2323                $old_user_id = bp_loggedin_user_id();
    24                 $this->set_current_user( self::$user_id );
     24                self::set_current_user( self::$user_id );
    2525
    2626                $group_id = groups_create_group( array(
     
    3131                $group = groups_get_group( $group_id );
    3232
    33                 $this->set_current_user( $old_user_id );
     33                self::set_current_user( $old_user_id );
    3434
    3535                $this->assertSame( self::$user_id + 1, $group->creator_id );
     
    4141        public function test_creator_id_should_be_fall_back_to_loggedin_user_for_new_group() {
    4242                $old_user_id = bp_loggedin_user_id();
    43                 $this->set_current_user( self::$user_id );
     43                self::set_current_user( self::$user_id );
    4444
    4545                $group_id = groups_create_group( array(
     
    4949                $group = groups_get_group( $group_id );
    5050
    51                 $this->set_current_user( $old_user_id );
     51                self::set_current_user( $old_user_id );
    5252
    5353                $this->assertSame( self::$user_id, $group->creator_id );
     
    6363
    6464                $old_user_id = bp_loggedin_user_id();
    65                 $this->set_current_user( self::$user_id );
     65                self::set_current_user( self::$user_id );
    6666
    6767                $group_id = groups_create_group( array(
     
    7171                $group = groups_get_group( $group_id );
    7272
    73                 $this->set_current_user( $old_user_id );
     73                self::set_current_user( $old_user_id );
    7474
    7575                $this->assertSame( self::$user_id + 1, $group->creator_id );
  • trunk/tests/phpunit/testcases/groups/notifications.php

    r13873 r13980  
    1414                parent::set_up();
    1515                $this->current_user = get_current_user_id();
    16                 $this->set_current_user( self::factory()->user->create() );
     16                self::set_current_user( self::factory()->user->create() );
    1717
    1818                $this->requesting_user_id = self::factory()->user->create();
     
    2222
    2323        public function tear_down() {
     24                self::set_current_user( $this->current_user );
     25
    2426                parent::tear_down();
    25                 $this->set_current_user( $this->current_user );
    2627        }
    2728
     
    299300                $this->assertEmpty( $u1_notifications );
    300301        }
    301 
    302302}
  • trunk/tests/phpunit/testcases/groups/template.php

    r13503 r13980  
    903903                // Fool the admin check
    904904                $old_user = get_current_user_id();
    905                 $this->set_current_user( $u2 );
     905                self::set_current_user( $u2 );
    906906                buddypress()->is_item_admin = true;
    907907                groups_ban_member( $u1, $g2 );
    908908
    909909                // Start the groups loop
    910                 $this->set_current_user( $u1 );
     910                self::set_current_user( $u1 );
    911911                if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group();
    912912                        $found[] = bp_group_is_user_banned();
     
    919919                // Clean up
    920920                $GLOBALS['groups_template'] = null;
    921                 $this->set_current_user( $old_user );
     921                self::set_current_user( $old_user );
    922922        }
    923923
     
    949949                // Fool the admin check
    950950                $old_user = get_current_user_id();
    951                 $this->set_current_user( $u2 );
     951                self::set_current_user( $u2 );
    952952                buddypress()->is_item_admin = true;
    953953                groups_ban_member( $u1, $g2 );
     
    966966
    967967                // Clean up
    968                 $this->set_current_user( $old_user );
     968                self::set_current_user( $old_user );
    969969        }
    970970
     
    973973         */
    974974        public function test_bp_group_is_forum_enabled() {
    975                 $g1 = $this->factory->group->create( array( 'enable_forum' => 0 ) );
    976                 $g2 = $this->factory->group->create( array( 'enable_forum' => 1 ) );
     975                $g1 = self::factory()->group->create( array( 'enable_forum' => 0 ) );
     976                $g2 = self::factory()->group->create( array( 'enable_forum' => 1 ) );
    977977
    978978                $this->assertFalse( bp_group_is_forum_enabled( $g1 ) );
     
    10051005         */
    10061006        public function test_bp_bp_get_group_form_action() {
    1007                 $g   = $this->factory->group->create();
     1007                $g   = self::factory()->group->create();
    10081008                $p   = 'members';
    10091009                $url = bp_get_group_url(
     
    10211021         */
    10221022        public function test_bp_get_group_member_count_0_members() {
    1023                 $u = $this->factory->user->create();
    1024                 $g = $this->factory->group->create( array( 'creator_id' => $u ) );
     1023                $u = self::factory()->user->create();
     1024                $g = self::factory()->group->create( array( 'creator_id' => $u ) );
    10251025
    10261026                // Fake the current group.
     
    10381038         */
    10391039        public function test_bp_get_group_member_count_1_member() {
    1040                 $g = $this->factory->group->create();
     1040                $g = self::factory()->group->create();
    10411041
    10421042                // Fake the current group.
     
    10511051         */
    10521052        public function test_bp_get_group_member_count_2_members() {
    1053                 $u1 = $this->factory->user->create();
    1054                 $u2 = $this->factory->user->create();
    1055                 $g  = $this->factory->group->create( array( 'creator_id' => $u1 ) );
     1053                $u1 = self::factory()->user->create();
     1054                $u2 = self::factory()->user->create();
     1055                $g  = self::factory()->group->create( array( 'creator_id' => $u1 ) );
    10561056
    10571057                $this->add_user_to_group( $u2, $g );
  • trunk/tests/phpunit/testcases/groups/template/bpGroupStatusMessage.php

    r13314 r13980  
    1212                parent::set_up();
    1313                $this->current_user = bp_loggedin_user_id();
    14                 $this->set_current_user( 0 );
     14                self::set_current_user( 0 );
    1515
    1616                if ( isset( $GLOBALS['groups_template'] ) ) {
     
    2020
    2121        public function tear_down() {
    22                 $this->set_current_user( $this->current_user );
     22                self::set_current_user( $this->current_user );
    2323                if ( $this->groups_template ) {
    2424                        $GLOBALS['groups_template'] = $this->groups_template;
     
    3535                $g = self::factory()->group->create( array( 'status' => 'private' ) );
    3636
    37                 $this->set_current_user( $users[0] );
     37                self::set_current_user( $users[0] );
    3838
    3939                groups_invite_user( array(
     
    6161                $g = self::factory()->group->create( array( 'status' => 'private' ) );
    6262
    63                 $this->set_current_user( $u );
     63                self::set_current_user( $u );
    6464
    6565                if ( bp_has_groups( array( 'include' => array( $g ) ) ) ) {
     
    9898                $g = self::factory()->group->create( array( 'status' => 'private' ) );
    9999
    100                 $this->set_current_user( $u );
     100                self::set_current_user( $u );
    101101
    102102                groups_send_membership_request( array(
     
    123123                $g = self::factory()->group->create( array( 'status' => 'hidden' ) );
    124124
    125                 $this->set_current_user( $u );
     125                self::set_current_user( $u );
    126126
    127127                $group = groups_get_group( $g );
     
    140140                $groups = self::factory()->group->create_many( 2, array( 'status' => 'private' ) );
    141141
    142                 $this->set_current_user( $u );
     142                self::set_current_user( $u );
    143143
    144144                // Fake the current group.
  • trunk/tests/phpunit/testcases/groups/template/group-is-visible.php

    r13414 r13980  
    2525
    2626        public function test_bp_group_is_visible_no_member() {
    27                 $g = $this->factory->group->create( array( 'status' => 'private' ) );
     27                $g = self::factory()->group->create( array( 'status' => 'private' ) );
    2828
    2929                $this->assertFalse( bp_group_is_visible( $g ) );
     
    3131
    3232        public function test_bp_group_is_visible_regular_member() {
    33                 $g = $this->factory->group->create( array( 'status' => 'private' ) );
    34                 $u = $this->factory->user->create();
     33                $g = self::factory()->group->create( array( 'status' => 'private' ) );
     34                $u = self::factory()->user->create();
    3535
    36                 $this->set_current_user( $u );
     36                self::set_current_user( $u );
    3737
    3838                $this->assertFalse( bp_group_is_visible( $g ) );
     
    4040
    4141        public function test_bp_group_is_visible_regular_member_from_group() {
    42                 $g = $this->factory->group->create( array( 'status' => 'private' ) );
    43                 $u = $this->factory->user->create();
     42                $g = self::factory()->group->create( array( 'status' => 'private' ) );
     43                $u = self::factory()->user->create();
    4444
    45                 $this->set_current_user( $u );
     45                self::set_current_user( $u );
    4646
    4747                $this->add_user_to_group( $u, $g );
     
    5151
    5252        public function test_bp_group_is_visible_invalid_group() {
    53                 $u = $this->factory->user->create();
     53                $u = self::factory()->user->create();
    5454
    5555                // Empty the current group.
     
    5757                $GLOBALS['groups_template']->group = null;
    5858
    59                 $this->set_current_user( $u );
     59                self::set_current_user( $u );
    6060
    6161                $this->assertFalse( bp_group_is_visible() );
     
    6363
    6464        public function test_bp_group_is_visible_admin() {
    65                 $g = $this->factory->group->create( array( 'status' => 'private' ) );
    66                 $u = $this->factory->user->create( array( 'role' => 'administrator' ) );
     65                $g = self::factory()->group->create( array( 'status' => 'private' ) );
     66                $u = self::factory()->user->create( array( 'role' => 'administrator' ) );
    6767
    68                 $this->set_current_user( $u );
     68                self::set_current_user( $u );
    6969
    7070                $this->assertTrue( bp_group_is_visible( $g ) );
     
    7272
    7373        public function test_bp_group_is_visible_using_user_id() {
    74                 $g = $this->factory->group->create( array( 'status' => 'hidden' ) );
    75                 $u = $this->factory->user->create();
     74                $g = self::factory()->group->create( array( 'status' => 'hidden' ) );
     75                $u = self::factory()->user->create();
    7676
    7777                $this->add_user_to_group( $u, $g );
     
    8181
    8282        public function test_bp_group_is_not_visible_using_user_id() {
    83                 $g = $this->factory->group->create( array( 'status' => 'private' ) );
    84                 $u = $this->factory->user->create();
     83                $g = self::factory()->group->create( array( 'status' => 'private' ) );
     84                $u = self::factory()->user->create();
    8585
    8686                $this->assertFalse( bp_group_is_visible( $g, $u ) );
     
    9090                $slug = 'test-group';
    9191
    92                 $this->factory->group->create(
     92                self::factory()->group->create(
    9393                        array(
    9494                                'status' => 'private',
     
    9797                );
    9898
    99                 $u = $this->factory->user->create( array( 'role' => 'administrator' ) );
     99                $u = self::factory()->user->create( array( 'role' => 'administrator' ) );
    100100
    101                 $this->set_current_user( $u );
     101                self::set_current_user( $u );
    102102
    103103                $this->assertTrue( bp_group_is_visible( $slug ) );
     
    105105
    106106        public function test_bp_group_is_visible_from_current_group() {
    107                 $g = $this->factory->group->create( array( 'status' => 'private' ) );
    108                 $u = $this->factory->user->create( array( 'role' => 'administrator' ) );
     107                $g = self::factory()->group->create( array( 'status' => 'private' ) );
     108                $u = self::factory()->user->create( array( 'role' => 'administrator' ) );
    109109
    110110                // Fake the current group.
     
    112112                $GLOBALS['groups_template']->group = groups_get_group( $g );
    113113
    114                 $this->set_current_user( $u );
     114                self::set_current_user( $u );
    115115
    116116                $this->assertTrue( bp_group_is_visible() );
  • trunk/tests/phpunit/testcases/groups/user_can.php

    r12440 r13980  
    77
    88        public function test_user_can_join_public_group() {
    9                 $g1 = $this->factory->group->create( array(
    10                         'status'      => 'public'
    11                 ) );
    12                 $u1 = $this->factory->user->create();
     9                $g1 = self::factory()->group->create( array(
     10                        'status'      => 'public'
     11                ) );
     12                $u1 = self::factory()->user->create();
    1313
    1414                $this->assertTrue( bp_user_can( $u1, 'groups_join_group', array( 'group_id' => $g1 ) ) );
     
    1616
    1717        public function test_user_cannot_join_public_group_if_already_member() {
    18                 $g1 = $this->factory->group->create( array(
    19                         'status'      => 'public'
    20                 ) );
    21                 $u1 = $this->factory->user->create();
     18                $g1 = self::factory()->group->create( array(
     19                        'status'      => 'public'
     20                ) );
     21                $u1 = self::factory()->user->create();
    2222                $this->add_user_to_group( $u1, $g1 );
    2323
     
    3333                }
    3434
    35                 $g1 = $this->factory->group->create( array(
    36                         'status'      => 'public'
    37                 ) );
    38                 $u1 = $this->factory->user->create();
     35                $g1 = self::factory()->group->create( array(
     36                        'status'      => 'public'
     37                ) );
     38                $u1 = self::factory()->user->create();
    3939                $this->add_user_to_group( $u1, $g1 );
    4040
     
    4646
    4747        public function test_user_cannot_join_private_group() {
    48                 $g1 = $this->factory->group->create( array(
    49                         'status'      => 'private'
    50                 ) );
    51                 $u1 = $this->factory->user->create();
     48                $g1 = self::factory()->group->create( array(
     49                        'status'      => 'private'
     50                ) );
     51                $u1 = self::factory()->user->create();
    5252
    5353                $this->assertFalse( bp_user_can( $u1, 'groups_join_group', array( 'group_id' => $g1 ) ) );
     
    5555
    5656        public function test_user_cannot_join_group_if_banned() {
    57                 $g1 = $this->factory->group->create( array(
    58                         'status'      => 'public'
    59                 ) );
    60                 $u1 = $this->factory->user->create();
     57                $g1 = self::factory()->group->create( array(
     58                        'status'      => 'public'
     59                ) );
     60                $u1 = self::factory()->user->create();
    6161                $this->add_user_to_group( $u1, $g1 );
    6262
     
    6868
    6969        public function test_user_cannot_request_membership_in_public_group() {
    70                 $g1 = $this->factory->group->create( array(
    71                         'status'      => 'public'
    72                 ) );
    73                 $u1 = $this->factory->user->create();
     70                $g1 = self::factory()->group->create( array(
     71                        'status'      => 'public'
     72                ) );
     73                $u1 = self::factory()->user->create();
    7474
    7575                $this->assertFalse( bp_user_can( $u1, 'groups_request_membership', array( 'group_id' => $g1 ) ) );
     
    7777
    7878        public function test_user_can_request_membership_in_private_group() {
    79                 $g1 = $this->factory->group->create( array(
    80                         'status'      => 'private'
    81                 ) );
    82                 $u1 = $this->factory->user->create();
     79                $g1 = self::factory()->group->create( array(
     80                        'status'      => 'private'
     81                ) );
     82                $u1 = self::factory()->user->create();
    8383
    8484                $this->assertTrue( bp_user_can( $u1, 'groups_request_membership', array( 'group_id' => $g1 ) ) );
     
    8686
    8787        public function test_user_cannot_request_membership_in_hidden_group() {
    88                 $g1 = $this->factory->group->create( array(
    89                         'status'      => 'hidden'
    90                 ) );
    91                 $u1 = $this->factory->user->create();
     88                $g1 = self::factory()->group->create( array(
     89                        'status'      => 'hidden'
     90                ) );
     91                $u1 = self::factory()->user->create();
    9292
    9393                $this->assertFalse( bp_user_can( $u1, 'groups_request_membership', array( 'group_id' => $g1 ) ) );
     
    9595
    9696        public function test_user_cannot_request_membership_in_private_group_if_already_member() {
    97                 $g1 = $this->factory->group->create( array(
    98                         'status'      => 'private'
    99                 ) );
    100                 $u1 = $this->factory->user->create();
     97                $g1 = self::factory()->group->create( array(
     98                        'status'      => 'private'
     99                ) );
     100                $u1 = self::factory()->user->create();
    101101                $this->add_user_to_group( $u1, $g1 );
    102102
     
    105105
    106106        public function test_user_cannot_request_membership_in_private_group_if_already_requested() {
    107                 $g1 = $this->factory->group->create( array(
    108                         'status'      => 'private'
    109                 ) );
    110                 $u1 = $this->factory->user->create();
     107                $g1 = self::factory()->group->create( array(
     108                        'status'      => 'private'
     109                ) );
     110                $u1 = self::factory()->user->create();
    111111                groups_send_membership_request( array(
    112112                        'user_id' => $u1,
     
    118118
    119119        public function test_user_cannot_request_membership_in_private_group_if_banned() {
    120                 $g1 = $this->factory->group->create( array(
    121                         'status'      => 'private'
    122                 ) );
    123                 $u1 = $this->factory->user->create();
     120                $g1 = self::factory()->group->create( array(
     121                        'status'      => 'private'
     122                ) );
     123                $u1 = self::factory()->user->create();
    124124                $this->add_user_to_group( $u1, $g1 );
    125125
     
    131131
    132132        public function test_user_can_receive_invitation_to_private_group() {
    133                 $g1 = $this->factory->group->create( array(
    134                         'status'      => 'private'
    135                 ) );
    136                 $u1 = $this->factory->user->create();
     133                $g1 = self::factory()->group->create( array(
     134                        'status'      => 'private'
     135                ) );
     136                $u1 = self::factory()->user->create();
    137137
    138138                $this->assertTrue( bp_user_can( $u1, 'groups_receive_invitation', array( 'group_id' => $g1 ) ) );
     
    140140
    141141        public function test_user_cannot_receive_invitation_to_private_group_if_already_member() {
    142                 $g1 = $this->factory->group->create( array(
    143                         'status'      => 'private'
    144                 ) );
    145                 $u1 = $this->factory->user->create();
     142                $g1 = self::factory()->group->create( array(
     143                        'status'      => 'private'
     144                ) );
     145                $u1 = self::factory()->user->create();
    146146                $this->add_user_to_group( $u1, $g1 );
    147147
     
    157157                }
    158158
    159                 $g1 = $this->factory->group->create( array(
    160                         'status'      => 'private'
    161                 ) );
    162                 $u1 = $this->factory->user->create();
     159                $g1 = self::factory()->group->create( array(
     160                        'status'      => 'private'
     161                ) );
     162                $u1 = self::factory()->user->create();
    163163                $this->add_user_to_group( $u1, $g1 );
    164164
     
    170170
    171171        public function test_user_cannot_receive_invitation_to_private_group_if_banned() {
    172                 $g1 = $this->factory->group->create( array(
    173                         'status'      => 'private'
    174                 ) );
    175                 $u1 = $this->factory->user->create();
     172                $g1 = self::factory()->group->create( array(
     173                        'status'      => 'private'
     174                ) );
     175                $u1 = self::factory()->user->create();
    176176                $this->add_user_to_group( $u1, $g1 );
    177177
     
    183183
    184184        public function test_user_can_receive_invitation_to_hidden_group() {
    185                 $g1 = $this->factory->group->create( array(
    186                         'status'      => 'hidden'
    187                 ) );
    188                 $u1 = $this->factory->user->create();
     185                $g1 = self::factory()->group->create( array(
     186                        'status'      => 'hidden'
     187                ) );
     188                $u1 = self::factory()->user->create();
    189189
    190190                $this->assertTrue( bp_user_can( $u1, 'groups_receive_invitation', array( 'group_id' => $g1 ) ) );
     
    192192
    193193        public function test_user_cannot_send_invitation_to_public_group_if_not_a_member() {
    194                 $g1 = $this->factory->group->create( array(
    195                         'status'      => 'public'
    196                 ) );
    197                 $u1 = $this->factory->user->create();
     194                $g1 = self::factory()->group->create( array(
     195                        'status'      => 'public'
     196                ) );
     197                $u1 = self::factory()->user->create();
    198198
    199199                $this->assertFalse( bp_user_can( $u1, 'groups_send_invitation', array( 'group_id' => $g1 ) ) );
     
    201201
    202202        public function test_user_cannot_send_invitation_to_private_group_if_not_a_member() {
    203                 $g1 = $this->factory->group->create( array(
    204                         'status'      => 'private'
    205                 ) );
    206                 $u1 = $this->factory->user->create();
     203                $g1 = self::factory()->group->create( array(
     204                        'status'      => 'private'
     205                ) );
     206                $u1 = self::factory()->user->create();
    207207
    208208                $this->assertFalse( bp_user_can( $u1, 'groups_send_invitation', array( 'group_id' => $g1 ) ) );
     
    210210
    211211        public function test_user_cannot_send_invitation_to_private_group_if_banned() {
    212                 $g1 = $this->factory->group->create( array(
     212                $g1 = self::factory()->group->create( array(
    213213                        'status'      => 'private'
    214214                ) );
    215215                groups_update_groupmeta( $g1, 'invite_status', 'members' );
    216                 $u1 = $this->factory->user->create();
     216                $u1 = self::factory()->user->create();
    217217                $this->add_user_to_group( $u1, $g1 );
    218218
     
    224224
    225225        public function test_user_can_send_invitation_to_private_group_if_a_member() {
    226                 $g1 = $this->factory->group->create( array(
     226                $g1 = self::factory()->group->create( array(
    227227                        'status'      => 'private',
    228228
    229229                ) );
    230230                groups_update_groupmeta( $g1, 'invite_status', 'members' );
    231                 $u1 = $this->factory->user->create();
     231                $u1 = self::factory()->user->create();
    232232                $this->add_user_to_group( $u1, $g1 );
    233233
     
    236236
    237237        public function test_user_can_send_invitation_to_hidden_group_if_a_member() {
    238                 $g1 = $this->factory->group->create( array(
    239                         'status'      => 'hidden'
    240                 ) );
    241                 $u1 = $this->factory->user->create();
    242                 $u1 = $this->factory->user->create();
     238                $g1 = self::factory()->group->create( array(
     239                        'status'      => 'hidden'
     240                ) );
     241                $u1 = self::factory()->user->create();
     242                $u1 = self::factory()->user->create();
    243243                $this->add_user_to_group( $u1, $g1 );
    244244
     
    247247
    248248        public function test_user_can_access_public_group_even_when_not_logged_in() {
    249                 $g1 = $this->factory->group->create( array(
    250                         'status'      => 'public'
    251                 ) );
    252                 $old_user = get_current_user_id();
    253                 $this->set_current_user( 0 );
     249                $g1 = self::factory()->group->create( array(
     250                        'status'      => 'public'
     251                ) );
     252                $old_user = get_current_user_id();
     253                self::set_current_user( 0 );
    254254
    255255                $this->assertTrue( bp_user_can( 0, 'groups_access_group', array( 'group_id' => $g1 ) ) );
    256256
    257                 $this->set_current_user( $old_user );
     257                self::set_current_user( $old_user );
    258258        }
    259259
    260260        public function test_user_can_access_public_group_if_not_a_member() {
    261                 $g1 = $this->factory->group->create( array(
    262                         'status'      => 'public'
    263                 ) );
    264                 $u1 = $this->factory->user->create();
     261                $g1 = self::factory()->group->create( array(
     262                        'status'      => 'public'
     263                ) );
     264                $u1 = self::factory()->user->create();
    265265
    266266                $this->assertTrue( bp_user_can( $u1, 'groups_access_group', array( 'group_id' => $g1 ) ) );
     
    268268
    269269        public function test_user_cannot_access_private_group_if_not_logged_in() {
    270                 $g1 = $this->factory->group->create( array(
    271                         'status'      => 'private'
    272                 ) );
    273                 $old_user = get_current_user_id();
    274                 $this->set_current_user( 0 );
     270                $g1 = self::factory()->group->create( array(
     271                        'status'      => 'private'
     272                ) );
     273                $old_user = get_current_user_id();
     274                self::set_current_user( 0 );
    275275
    276276                $this->assertFalse( bp_user_can( 0, 'groups_access_group', array( 'group_id' => $g1 ) ) );
    277277
    278                 $this->set_current_user( $old_user );
     278                self::set_current_user( $old_user );
    279279        }
    280280
    281281        public function test_user_cannot_access_private_group_if_not_a_member() {
    282                 $g1 = $this->factory->group->create( array(
    283                         'status'      => 'private'
    284                 ) );
    285                 $u1 = $this->factory->user->create();
     282                $g1 = self::factory()->group->create( array(
     283                        'status'      => 'private'
     284                ) );
     285                $u1 = self::factory()->user->create();
    286286
    287287                $this->assertFalse( bp_user_can( $u1, 'groups_access_group', array( 'group_id' => $g1 ) ) );
     
    289289
    290290        public function test_user_can_access_private_group_if_a_member() {
    291                 $g1 = $this->factory->group->create( array(
    292                         'status'      => 'private'
    293                 ) );
    294                 $u1 = $this->factory->user->create();
     291                $g1 = self::factory()->group->create( array(
     292                        'status'      => 'private'
     293                ) );
     294                $u1 = self::factory()->user->create();
    295295                $this->add_user_to_group( $u1, $g1 );
    296296
     
    299299
    300300        public function test_user_cannot_access_hidden_group_if_not_logged_in() {
    301                 $g1 = $this->factory->group->create( array(
    302                         'status'      => 'hidden'
    303                 ) );
    304                 $old_user = get_current_user_id();
    305                 $this->set_current_user( 0 );
     301                $g1 = self::factory()->group->create( array(
     302                        'status'      => 'hidden'
     303                ) );
     304                $old_user = get_current_user_id();
     305                self::set_current_user( 0 );
    306306
    307307                $this->assertFalse( bp_user_can( 0, 'groups_access_group', array( 'group_id' => $g1 ) ) );
    308308
    309                 $this->set_current_user( $old_user );
     309                self::set_current_user( $old_user );
    310310        }
    311311
    312312        public function test_user_cannot_access_hidden_group_if_not_a_member() {
    313                 $g1 = $this->factory->group->create( array(
    314                         'status'      => 'hidden'
    315                 ) );
    316                 $u1 = $this->factory->user->create();
     313                $g1 = self::factory()->group->create( array(
     314                        'status'      => 'hidden'
     315                ) );
     316                $u1 = self::factory()->user->create();
    317317
    318318                $this->assertFalse( bp_user_can( $u1, 'groups_access_group', array( 'group_id' => $g1 ) ) );
     
    320320
    321321        public function test_user_can_access_hidden_group_if_a_member() {
    322                 $g1 = $this->factory->group->create( array(
    323                         'status'      => 'hidden'
    324                 ) );
    325                 $u1 = $this->factory->user->create();
     322                $g1 = self::factory()->group->create( array(
     323                        'status'      => 'hidden'
     324                ) );
     325                $u1 = self::factory()->user->create();
    326326                $this->add_user_to_group( $u1, $g1 );
    327327
     
    330330
    331331        public function test_user_can_see_public_group_even_when_not_logged_in() {
    332                 $g1 = $this->factory->group->create( array(
    333                         'status'      => 'public'
    334                 ) );
    335                 $old_user = get_current_user_id();
    336                 $this->set_current_user( 0 );
     332                $g1 = self::factory()->group->create( array(
     333                        'status'      => 'public'
     334                ) );
     335                $old_user = get_current_user_id();
     336                self::set_current_user( 0 );
    337337
    338338                $this->assertTrue( bp_user_can( 0, 'groups_see_group', array( 'group_id' => $g1 ) ) );
    339339
    340                 $this->set_current_user( $old_user );
     340                self::set_current_user( $old_user );
    341341        }
    342342
    343343        public function test_user_can_see_public_group() {
    344                 $g1 = $this->factory->group->create( array(
    345                         'status'      => 'public'
    346                 ) );
    347                 $u1 = $this->factory->user->create();
     344                $g1 = self::factory()->group->create( array(
     345                        'status'      => 'public'
     346                ) );
     347                $u1 = self::factory()->user->create();
    348348
    349349                $this->assertTrue( bp_user_can( $u1, 'groups_see_group', array( 'group_id' => $g1 ) ) );
     
    351351
    352352        public function test_user_can_see_private_group_even_when_not_logged_in() {
    353                 $g1 = $this->factory->group->create( array(
    354                         'status'      => 'private'
    355                 ) );
    356                 $old_user = get_current_user_id();
    357                 $this->set_current_user( 0 );
     353                $g1 = self::factory()->group->create( array(
     354                        'status'      => 'private'
     355                ) );
     356                $old_user = get_current_user_id();
     357                self::set_current_user( 0 );
    358358
    359359                $this->assertTrue( bp_user_can( 0, 'groups_see_group', array( 'group_id' => $g1 ) ) );
    360360
    361                 $this->set_current_user( $old_user );
     361                self::set_current_user( $old_user );
    362362        }
    363363
    364364        public function test_user_can_see_private_group() {
    365                 $g1 = $this->factory->group->create( array(
    366                         'status'      => 'private'
    367                 ) );
    368                 $u1 = $this->factory->user->create();
     365                $g1 = self::factory()->group->create( array(
     366                        'status'      => 'private'
     367                ) );
     368                $u1 = self::factory()->user->create();
    369369
    370370                $this->assertTrue( bp_user_can( $u1, 'groups_see_group', array( 'group_id' => $g1 ) ) );
     
    372372
    373373        public function test_user_cannot_see_hidden_group_if_not_logged_in() {
    374                 $g1 = $this->factory->group->create( array(
    375                         'status'      => 'hidden'
    376                 ) );
    377                 $old_user = get_current_user_id();
    378                 $this->set_current_user( 0 );
     374                $g1 = self::factory()->group->create( array(
     375                        'status'      => 'hidden'
     376                ) );
     377                $old_user = get_current_user_id();
     378                self::set_current_user( 0 );
    379379
    380380                $this->assertFalse( bp_user_can( 0, 'groups_see_group', array( 'group_id' => $g1 ) ) );
    381381
    382                 $this->set_current_user( $old_user );
     382                self::set_current_user( $old_user );
    383383        }
    384384
    385385        public function test_user_cannot_see_hidden_group_if_not_a_member() {
    386                 $g1 = $this->factory->group->create( array(
    387                         'status'      => 'hidden'
    388                 ) );
    389                 $u1 = $this->factory->user->create();
     386                $g1 = self::factory()->group->create( array(
     387                        'status'      => 'hidden'
     388                ) );
     389                $u1 = self::factory()->user->create();
    390390
    391391                $this->assertFalse( bp_user_can( $u1, 'groups_see_group', array( 'group_id' => $g1 ) ) );
     
    393393
    394394        public function test_user_can_see_hidden_group_if_member() {
    395                 $g1 = $this->factory->group->create( array(
    396                         'status'      => 'hidden'
    397                 ) );
    398                 $u1 = $this->factory->user->create();
     395                $g1 = self::factory()->group->create( array(
     396                        'status'      => 'hidden'
     397                ) );
     398                $u1 = self::factory()->user->create();
    399399                $this->add_user_to_group( $u1, $g1 );
    400400
     
    410410                }
    411411
    412                 $g1 = $this->factory->group->create( array(
     412                $g1 = self::factory()->group->create( array(
    413413                        'status' => 'public'
    414414                ) );
    415                 $u1 = $this->factory->user->create();
     415                $u1 = self::factory()->user->create();
    416416                $this->add_user_to_group( $u1, $g1 );
    417417
  • trunk/tests/phpunit/testcases/members/activity.php

    r13180 r13980  
    130130                $prev_time = date( 'Y-m-d H:i:s', $time - ( 121 * HOUR_IN_SECONDS ) );
    131131
    132                 $a = self::factory()->activity->create( array(
     132                self::factory()->activity->create( array(
    133133                        'component'     => buddypress()->members->id,
    134134                        'type'          => 'new_avatar',
     
    161161                $prev_time      = date( 'Y-m-d H:i:s', $prev_timestamp );
    162162
    163                 $a1 = self::factory()->activity->create( array(
     163                self::factory()->activity->create( array(
    164164                        'component'     => buddypress()->members->id,
    165165                        'type'          => 'new_avatar',
     
    168168                ) );
    169169
    170                 $a2 = self::factory()->activity->create(
     170                self::factory()->activity->create(
    171171                        array(
    172172                                'component'     => buddypress()->members->id,
  • trunk/tests/phpunit/testcases/members/class-bp-signup.php

    r13314 r13980  
    1010
    1111        public function set_up() {
    12 
    1312                if ( is_multisite() ) {
    1413                        $this->signup_allowed = get_site_option( 'registration' );
  • trunk/tests/phpunit/testcases/members/functions.php

    r13894 r13980  
    3333
    3434                // 1. Admin can delete user account
    35                 $this->set_current_user( $admin_user );
     35                self::set_current_user( $admin_user );
    3636                $user1 = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    3737                bp_core_delete_account( $user1 );
     
    5252                $user3 = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    5353                $user4 = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    54                 $this->set_current_user( $user3 );
     54                self::set_current_user( $user3 );
    5555                bp_core_delete_account( $user4 );
    5656                $maybe_user = new WP_User( $user4 );
     
    5959
    6060                // Cleanup
    61                 $this->set_current_user( $current_user );
     61                self::set_current_user( $current_user );
    6262                bp_update_option( 'bp-disable-account-deletion', $deletion_disabled );
    6363        }
     
    747747
    748748                // Create the signup.
    749                 $this->factory->signup->create( array(
     749                self::factory()->signup->create( array(
    750750                        'user_login'     => 'test',
    751751                        'user_email'     => 'test@example.com',
  • trunk/tests/phpunit/testcases/members/template.php

    r13433 r13980  
    7272
    7373                $old_user = get_current_user_id();
    74                 $this->set_current_user( $u2 );
     74                self::set_current_user( $u2 );
    7575                $this->set_permalink_structure( '/%postname%/' );
    7676
     
    9595                $this->assertEquals( $request_ids, array( $u1 ) );
    9696
    97                 $this->set_current_user( $old_user );
     97                self::set_current_user( $old_user );
    9898        }
    9999
     
    108108
    109109                $old_user = get_current_user_id();
    110                 $this->set_current_user( $u2 );
     110                self::set_current_user( $u2 );
    111111                $this->set_permalink_structure( '/%postname%/' );
    112112
     
    137137                $this->assertEquals( array(), $request_ids );
    138138
    139                 $this->set_current_user( $old_user );
     139                self::set_current_user( $old_user );
    140140        }
    141141
  • trunk/tests/phpunit/testcases/members/template/bpGetMemberTypeDirectoryPermalink.php

    r13436 r13980  
    1616
    1717        public function tear_down() {
     18                $this->set_permalink_structure( $this->permalink_structure );
     19
    1820                parent::tear_down();
    19 
    20                 $this->set_permalink_structure( $this->permalink_structure );
    2121        }
    2222
  • trunk/tests/phpunit/testcases/messages/cache.php

    r13414 r13980  
    145145                // delete thread
    146146                // to outright delete a thread, both recipients must delete it
    147                 $this->set_current_user( $u1 );
     147                self::set_current_user( $u1 );
    148148                messages_delete_thread( $t1 );
    149                 $this->set_current_user( $u2 );
     149                self::set_current_user( $u2 );
    150150                messages_delete_thread( $t1 );
    151151
     
    155155
    156156                // cleanup
    157                 $this->set_current_user( $this->old_current_user );
     157                self::set_current_user( $this->old_current_user );
    158158        }
    159159
  • trunk/tests/phpunit/testcases/messages/class.bp-messages-notice.php

    r13314 r13980  
    1010        public function set_up() {
    1111                parent::set_up();
     12
    1213                $this->old_current_user = get_current_user_id();
    13                 $this->set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     14                self::set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    1415        }
    1516
    1617        public function tear_down() {
     18                self::set_current_user( $this->old_current_user );
     19
    1720                parent::tear_down();
    18                 $this->set_current_user( $this->old_current_user );
    1921        }
    2022
     
    5052                $this->assertEquals( $message2, $cache->message );
    5153        }
    52 
    5354}
  • trunk/tests/phpunit/testcases/messages/class.bp-messages-thread.php

    r13859 r13980  
    572572                // Mark thread as read
    573573                $current_user = get_current_user_id();
    574                 $this->set_current_user( $u2 );
     574                self::set_current_user( $u2 );
    575575                messages_mark_thread_read( $t1 );
    576576
     
    578578                $this->assertFalse( wp_cache_get( 'thread_recipients_' . $t1, 'bp_messages' ) );
    579579
    580                 $this->set_current_user( $current_user );
     580                self::set_current_user( $current_user );
    581581        }
    582582
     
    674674                // Mark thread as unread
    675675                $current_user = get_current_user_id();
    676                 $this->set_current_user( $u2 );
     676                self::set_current_user( $u2 );
    677677                messages_mark_thread_unread( $t1 );
    678678
     
    680680                $this->assertFalse( wp_cache_get( 'thread_recipients_' . $t1, 'bp_messages' ) );
    681681
    682                 $this->set_current_user( $current_user );
     682                self::set_current_user( $current_user );
    683683        }
    684684
  • trunk/tests/phpunit/testcases/messages/functions.php

    r12403 r13980  
    2323
    2424                // get unread count for $u2
    25                 $this->set_current_user( $u2 );
     25                self::set_current_user( $u2 );
    2626                $this->assertEquals( 1, messages_get_unread_count( $u2 ) );
    2727
  • trunk/tests/phpunit/testcases/messages/notifications.php

    r13414 r13980  
    88class BP_Tests_Messages_Notifications extends BP_UnitTestCase {
    99
     10        protected $reset_user_id = 0;
    1011        protected $filter_fired;
    1112
     
    1415
    1516                $this->reset_user_id = get_current_user_id();
    16 
    1717                $this->filter_fired = '';
    1818        }
    1919
    2020        public function tear_down() {
     21                self::set_current_user( $this->reset_user_id );
     22
    2123                parent::tear_down();
    22 
    23                 $this->set_current_user( $this->reset_user_id );
    2424        }
    2525
     
    3131                $t = 12;
    3232                $u = self::factory()->user->create();
    33                 $this->set_current_user( $u );
     33                self::set_current_user( $u );
    3434
    3535                // Admin
     
    5555                $t = 12;
    5656                $u = self::factory()->user->create();
    57                 $this->set_current_user( $u );
     57                self::set_current_user( $u );
    5858
    5959                // Admin
     
    7979                $t = 12;
    8080                $u = self::factory()->user->create();
    81                 $this->set_current_user( $u );
     81                self::set_current_user( $u );
    8282
    8383                // Admin
     
    103103                $t = 12;
    104104                $u = self::factory()->user->create();
    105                 $this->set_current_user( $u );
     105                self::set_current_user( $u );
    106106
    107107                // Admin
     
    189189                );
    190190
    191                 $this->set_current_user( $u1 );
     191                self::set_current_user( $u1 );
    192192
    193193                // Mark a thread read.
  • trunk/tests/phpunit/testcases/messages/star.php

    r11737 r13980  
    155155
    156156                // delete the second thread
    157                 $this->set_current_user( $u2 );
     157                self::set_current_user( $u2 );
    158158                messages_delete_thread( $t2 );
    159159
     
    169169
    170170                // reset
    171                 $this->set_current_user( $old_current_user );
     171                self::set_current_user( $old_current_user );
    172172        }
    173173
  • trunk/tests/phpunit/testcases/messages/template.php

    r13339 r13980  
    281281                // set user to anonymous
    282282                $old_current_user = get_current_user_id();
    283                 $this->set_current_user( 0 );
     283                self::set_current_user( 0 );
    284284
    285285                // now, do the message thread query
     
    291291                $this->assertEmpty( $messages_template->threads );
    292292
    293                 $this->set_current_user( $old_current_user );
     293                self::set_current_user( $old_current_user );
    294294        }
    295295
     
    462462                // set $u1 as current user.
    463463                $old_current_user = get_current_user_id();
    464                 $this->set_current_user( $u1 );
     464                self::set_current_user( $u1 );
    465465
    466466                $messages_template = new BP_Messages_Box_Template(
     
    471471                );
    472472
    473                 $this->set_current_user( $old_current_user );
     473                self::set_current_user( $old_current_user );
    474474
    475475                $thread = reset( $messages_template->threads );
  • trunk/tests/phpunit/testcases/routing/activity.php

    r13433 r13980  
    1313                $this->old_current_user = get_current_user_id();
    1414                $this->permalink_structure = get_option( 'permalink_structure', '' );
    15                 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
     15                self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1616        }
    1717
    1818        public function tear_down() {
     19                self::set_current_user( $this->old_current_user );
     20                $this->set_permalink_structure( $this->permalink_structure );
     21
    1922                parent::tear_down();
    20                 $this->set_current_user( $this->old_current_user );
    21                 $this->set_permalink_structure( $this->permalink_structure );
    2223        }
    2324
  • trunk/tests/phpunit/testcases/routing/core.php

    r13507 r13980  
    1212
    1313                $this->old_current_user = get_current_user_id();
    14                 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
     14                self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1515                $this->permalink_structure = get_option( 'permalink_structure', '' );
    1616        }
    1717
    1818        public function tear_down() {
     19                self::set_current_user( $this->old_current_user );
     20                $this->set_permalink_structure( $this->permalink_structure );
     21
    1922                parent::tear_down();
    20                 $this->set_current_user( $this->old_current_user );
    21                 $this->set_permalink_structure( $this->permalink_structure );
    2223        }
    2324
  • trunk/tests/phpunit/testcases/routing/friends.php

    r13433 r13980  
    1313                $this->old_current_user = get_current_user_id();
    1414                $this->permalink_structure = get_option( 'permalink_structure', '' );
    15                 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
     15                self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1616        }
    1717
    1818        public function tear_down() {
     19                self::set_current_user( $this->old_current_user );
     20                $this->set_permalink_structure( $this->permalink_structure );
     21
    1922                parent::tear_down();
    20                 $this->set_current_user( $this->old_current_user );
    21                 $this->set_permalink_structure( $this->permalink_structure );
    2223        }
    2324
  • trunk/tests/phpunit/testcases/routing/groups.php

    r13468 r13980  
    1414                $this->old_current_user = get_current_user_id();
    1515                $this->permalink_structure = get_option( 'permalink_structure', '' );
    16                 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
     16                self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1717        }
    1818
    1919        public function tear_down() {
     20                self::set_current_user( $this->old_current_user );
     21                $this->set_permalink_structure( $this->permalink_structure );
     22
    2023                parent::tear_down();
    21                 $this->set_current_user( $this->old_current_user );
    22                 $this->set_permalink_structure( $this->permalink_structure );
    2324        }
    2425
     
    219220                $this->assertEquals( $g2, bp_get_current_group_id() );
    220221        }
    221 
    222222}
  • trunk/tests/phpunit/testcases/routing/members.php

    r13720 r13980  
    1414                $this->old_current_user = get_current_user_id();
    1515                $this->permalink_structure = get_option( 'permalink_structure', '' );
    16                 $this->set_current_user( self::factory()->user->create( array( 'user_login' => 'paulgibbs', 'role' => 'subscriber' ) ) );
     16                self::set_current_user( self::factory()->user->create( array( 'user_login' => 'paulgibbs', 'role' => 'subscriber' ) ) );
    1717        }
    1818
    1919        public function tear_down() {
    20                 $this->set_current_user( $this->old_current_user );
     20                self::set_current_user( $this->old_current_user );
    2121                $this->set_permalink_structure( $this->permalink_structure );
     22
    2223                parent::tear_down();
    2324        }
  • trunk/tests/phpunit/testcases/routing/messages.php

    r13433 r13980  
    1313                $this->old_current_user = get_current_user_id();
    1414                $this->permalink_structure = get_option( 'permalink_structure', '' );
    15                 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
     15                self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1616        }
    1717
    1818        public function tear_down() {
     19                self::set_current_user( $this->old_current_user );
     20                $this->set_permalink_structure( $this->permalink_structure );
     21
    1922                parent::tear_down();
    20                 $this->set_current_user( $this->old_current_user );
    21                 $this->set_permalink_structure( $this->permalink_structure );
    2223        }
    2324
  • trunk/tests/phpunit/testcases/routing/root-profiles.php

    r13468 r13980  
    2121                ) );
    2222                $this->u = new WP_User( $uid );
    23                 $this->set_current_user( $uid );
     23                self::set_current_user( $uid );
    2424                $this->permalink_structure = get_option( 'permalink_structure', '' );
    2525        }
    2626
    2727        public function tear_down() {
    28                 parent::tear_down();
    29                 $this->set_current_user( $this->old_current_user );
     28                self::set_current_user( $this->old_current_user );
    3029                $this->set_permalink_structure( $this->permalink_structure );
    3130                remove_filter( 'bp_core_enable_root_profiles', '__return_true' );
     31
     32                parent::tear_down();
    3233        }
    3334
  • trunk/tests/phpunit/testcases/routing/settings.php

    r13433 r13980  
    1313                $this->old_current_user = get_current_user_id();
    1414                $this->permalink_structure = get_option( 'permalink_structure', '' );
    15                 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
     15                self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1616        }
    1717
    1818        public function tear_down() {
     19                self::set_current_user( $this->old_current_user );
     20                $this->set_permalink_structure( $this->permalink_structure );
     21
    1922                parent::tear_down();
    20                 $this->set_current_user( $this->old_current_user );
    21                 $this->set_permalink_structure( $this->permalink_structure );
    2223        }
    2324
  • trunk/tests/phpunit/testcases/routing/xprofile.php

    r13433 r13980  
    1313                $this->old_current_user = get_current_user_id();
    1414                $this->permalink_structure = get_option( 'permalink_structure', '' );
    15                 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
     15                self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1616        }
    1717
    1818        public function tear_down() {
     19                self::set_current_user( $this->old_current_user );
     20                $this->set_permalink_structure( $this->permalink_structure );
     21
    1922                parent::tear_down();
    20                 $this->set_current_user( $this->old_current_user );
    21                 $this->set_permalink_structure( $this->permalink_structure );
    2223        }
    2324
  • trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-field-type.php

    r13314 r13980  
    1616
    1717        public function tear_down() {
     18                remove_filter( 'bp_xprofile_get_field_types', array( $this, 'get_field_types' ) );
     19
    1820                parent::tear_down();
    19 
    20                 remove_filter( 'bp_xprofile_get_field_types', array( $this, 'get_field_types' ) );
    2121        }
    2222
  • trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-field.php

    r11847 r13980  
    218218
    219219                $old_user = get_current_user_id();
    220                 $this->set_current_user( $user );
     220                self::set_current_user( $user );
    221221
    222222                $value = bp_get_profile_field_data( array( 'user_id' => $user, 'field' => $field ) );
    223223                $this->assertEmpty( $value );
    224224
    225                 $this->set_current_user( $old_user );
     225                self::set_current_user( $old_user );
    226226        }
    227227
  • trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-query.php

    r13314 r13980  
    99        protected $fields = array();
    1010        protected $users = array();
    11 
    12         public function tear_down() {
    13                 parent::tear_down();
    14                 $this->group = '';
    15                 $this->fields = array();
    16                 $this->users = array();
    17         }
    1811
    1912        public function test_no_field() {
  • trunk/tests/phpunit/testcases/xprofile/functions.php

    r13792 r13980  
    1010
    1111                $old_current_user = bp_loggedin_user_id();
    12                 $this->set_current_user( 0 );
     12                self::set_current_user( 0 );
    1313
    1414                $this->assertEquals( array( 'friends', 'loggedin', 'adminsonly' ), bp_xprofile_get_hidden_field_types_for_user( $duser, bp_loggedin_user_id() ) );
    1515
    16                 $this->set_current_user( $old_current_user );
     16                self::set_current_user( $old_current_user );
    1717        }
    1818
     
    2222
    2323                $old_current_user = bp_loggedin_user_id();
    24                 $this->set_current_user( $cuser );
     24                self::set_current_user( $cuser );
    2525
    2626                $this->assertEquals( array( 'friends', 'adminsonly' ), bp_xprofile_get_hidden_field_types_for_user( $duser, bp_loggedin_user_id() ) );
    2727
    28                 $this->set_current_user( $old_current_user );
     28                self::set_current_user( $old_current_user );
    2929        }
    3030
     
    3535
    3636                $old_current_user = bp_loggedin_user_id();
    37                 $this->set_current_user( $cuser );
     37                self::set_current_user( $cuser );
    3838
    3939                $this->assertEquals( array( 'adminsonly' ), bp_xprofile_get_hidden_field_types_for_user( $duser, bp_loggedin_user_id() ) );
    4040
    41                 $this->set_current_user( $old_current_user );
     41                self::set_current_user( $old_current_user );
    4242        }
    4343
     
    4848
    4949                $old_current_user = bp_loggedin_user_id();
    50                 $this->set_current_user( $cuser );
     50                self::set_current_user( $cuser );
    5151
    5252                $this->assertEquals( array(), bp_xprofile_get_hidden_field_types_for_user( $duser, bp_loggedin_user_id() ) );
    5353
    5454                $this->revoke_bp_moderate( $cuser );
    55                 $this->set_current_user( $old_current_user );
     55                self::set_current_user( $old_current_user );
    5656        }
    5757
  • trunk/tests/phpunit/testcases/xprofile/template.php

    r13797 r13980  
    1919                );
    2020
    21                 $this->set_current_user( $u1 );
     21                self::set_current_user( $u1 );
    2222
    2323                bp_has_profile(
     
    3232                $this->assertEquals( 'Foo Bar', $field->data->value, 'The primary field should be the Name one and its value should be the same than the display name, by default' );
    3333
    34                 $this->set_current_user( $prev_user );
     34                self::set_current_user( $prev_user );
    3535                $profile_template = $reset_profile_template;
    3636        }
Note: See TracChangeset for help on using the changeset viewer.