Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/27/2024 04:30:23 PM (18 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/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}
Note: See TracChangeset for help on using the changeset viewer.