Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/27/2024 04:30:23 PM (19 months 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.