Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2017 07:44:10 PM (4 years ago)
Author:
boonebgorges
Message:

Use static factory method throughout PHPUnit tests.

See #7620.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/friends/functions.php

    r11354 r11737  
    2020     */
    2121    public function test_requests_on_accept() {
    22         $u1 = $this->factory->user->create();
    23         $u2 = $this->factory->user->create();
    24         $u3 = $this->factory->user->create();
     22        $u1 = self::factory()->user->create();
     23        $u2 = self::factory()->user->create();
     24        $u3 = self::factory()->user->create();
    2525
    2626        // request friendship
     
    5555     */
    5656    public function test_requests_on_request() {
    57         $u1 = $this->factory->user->create();
    58         $u2 = $this->factory->user->create();
    59         $u3 = $this->factory->user->create();
     57        $u1 = self::factory()->user->create();
     58        $u2 = self::factory()->user->create();
     59        $u3 = self::factory()->user->create();
    6060
    6161        // request friendship
     
    8585     */
    8686    public function test_requests_on_withdraw() {
    87         $u1 = $this->factory->user->create();
    88         $u2 = $this->factory->user->create();
     87        $u1 = self::factory()->user->create();
     88        $u2 = self::factory()->user->create();
    8989
    9090        // request friendship
     
    113113     */
    114114    public function test_requests_on_reject() {
    115         $u1 = $this->factory->user->create();
    116         $u2 = $this->factory->user->create();
     115        $u1 = self::factory()->user->create();
     116        $u2 = self::factory()->user->create();
    117117
    118118        // request friendship
     
    139139     */
    140140    public function test_friends_add_friend_fail_on_self() {
    141         $u1 = $this->factory->user->create();
     141        $u1 = self::factory()->user->create();
    142142        $this->assertFalse( friends_add_friend( $u1, $u1 ) );
    143143    }
     
    147147     */
    148148    public function test_friends_add_friend_already_friends() {
    149         $u1 = $this->factory->user->create();
    150         $u2 = $this->factory->user->create();
     149        $u1 = self::factory()->user->create();
     150        $u2 = self::factory()->user->create();
    151151
    152152        friends_add_friend( $u1, $u2, true );
     
    160160    public function test_friends_check_friendship_status_in_members_loop() {
    161161        $now = time();
    162         $u1 = $this->factory->user->create( array(
     162        $u1 = self::factory()->user->create( array(
    163163            'last_activity' => date( 'Y-m-d H:i:s', $now ),
    164164        ) );
    165         $u2 = $this->factory->user->create( array(
     165        $u2 = self::factory()->user->create( array(
    166166            'last_activity' => date( 'Y-m-d H:i:s', $now - 100 ),
    167167        ) );
    168         $u3 = $this->factory->user->create( array(
     168        $u3 = self::factory()->user->create( array(
    169169            'last_activity' => date( 'Y-m-d H:i:s', $now - 200 ),
    170170        ) );
    171         $u4 = $this->factory->user->create( array(
     171        $u4 = self::factory()->user->create( array(
    172172            'last_activity' => date( 'Y-m-d H:i:s', $now - 300 ),
    173173        ) );
    174         $u5 = $this->factory->user->create( array(
     174        $u5 = self::factory()->user->create( array(
    175175            'last_activity' => date( 'Y-m-d H:i:s', $now - 400 ),
    176176        ) );
     
    208208    public function test_friends_check_friendship_status_not_in_members_loop() {
    209209        $now = time();
    210         $u1 = $this->factory->user->create( array(
     210        $u1 = self::factory()->user->create( array(
    211211            'last_activity' => date( 'Y-m-d H:i:s', $now ),
    212212        ) );
    213         $u2 = $this->factory->user->create( array(
     213        $u2 = self::factory()->user->create( array(
    214214            'last_activity' => date( 'Y-m-d H:i:s', $now - 100 ),
    215215        ) );
    216         $u3 = $this->factory->user->create( array(
     216        $u3 = self::factory()->user->create( array(
    217217            'last_activity' => date( 'Y-m-d H:i:s', $now - 200 ),
    218218        ) );
    219         $u4 = $this->factory->user->create( array(
     219        $u4 = self::factory()->user->create( array(
    220220            'last_activity' => date( 'Y-m-d H:i:s', $now - 300 ),
    221221        ) );
    222         $u5 = $this->factory->user->create( array(
     222        $u5 = self::factory()->user->create( array(
    223223            'last_activity' => date( 'Y-m-d H:i:s', $now - 400 ),
    224224        ) );
     
    251251     */
    252252    public function test_friends_add_friend_friends_friendship_requested() {
    253         $u1 = $this->factory->user->create();
    254         $u2 = $this->factory->user->create();
     253        $u1 = self::factory()->user->create();
     254        $u2 = self::factory()->user->create();
    255255
    256256        add_filter( 'friends_friendship_requested', array( $this, 'friends_friendship_filter_callback' ) );
     
    265265     */
    266266    public function test_friends_add_friend_friends_friendship_accepted() {
    267         $u1 = $this->factory->user->create();
    268         $u2 = $this->factory->user->create();
     267        $u1 = self::factory()->user->create();
     268        $u2 = self::factory()->user->create();
    269269
    270270        add_filter( 'friends_friendship_accepted', array( $this, 'friends_friendship_filter_callback' ) );
     
    286286        global $wpdb;
    287287        $now = time();
    288         $u1 = $this->factory->user->create( array(
     288        $u1 = self::factory()->user->create( array(
    289289            'last_activity' => date( 'Y-m-d H:i:s', $now ),
    290290        ) );
    291         $u2 = $this->factory->user->create( array(
     291        $u2 = self::factory()->user->create( array(
    292292            'last_activity' => date( 'Y-m-d H:i:s', $now - 100 ),
    293293        ) );
    294         $u3 = $this->factory->user->create( array(
     294        $u3 = self::factory()->user->create( array(
    295295            'last_activity' => date( 'Y-m-d H:i:s', $now - 200 ),
    296296        ) );
     
    313313        global $wpdb;
    314314        $now = time();
    315         $u1 = $this->factory->user->create( array(
     315        $u1 = self::factory()->user->create( array(
    316316            'last_activity' => date( 'Y-m-d H:i:s', $now ),
    317317        ) );
    318         $u2 = $this->factory->user->create( array(
     318        $u2 = self::factory()->user->create( array(
    319319            'last_activity' => date( 'Y-m-d H:i:s', $now - 100 ),
    320320        ) );
     
    335335
    336336    public function test_friends_get_recently_active() {
    337         $u1 = $this->factory->user->create();
    338         $u2 = $this->factory->user->create();
    339         $u3 = $this->factory->user->create();
    340         $u4 = $this->factory->user->create();
     337        $u1 = self::factory()->user->create();
     338        $u2 = self::factory()->user->create();
     339        $u3 = self::factory()->user->create();
     340        $u4 = self::factory()->user->create();
    341341
    342342        // request friendship
     
    357357
    358358    public function test_friends_get_alphabetically() {
    359         $u1 = $this->factory->user->create();
    360         $u2 = $this->factory->user->create();
    361         $u3 = $this->factory->user->create();
     359        $u1 = self::factory()->user->create();
     360        $u2 = self::factory()->user->create();
     361        $u3 = self::factory()->user->create();
    362362
    363363        // request friendship
     
    378378
    379379    public function test_friends_get_newest() {
    380         $u1 = $this->factory->user->create();
    381         $u2 = $this->factory->user->create();
    382         $u3 = $this->factory->user->create();
    383         $u4 = $this->factory->user->create();
     380        $u1 = self::factory()->user->create();
     381        $u2 = self::factory()->user->create();
     382        $u3 = self::factory()->user->create();
     383        $u4 = self::factory()->user->create();
    384384
    385385        // request friendship
Note: See TracChangeset for help on using the changeset viewer.