Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2014 06:14:06 PM (10 years ago)
Author:
djpaul
Message:

Unit Tests, Groups: update the group factory to set the group's creator_id if one was not passed to the factory.

This is a quicker way of updating hundreds of unit tests where we've previously had a bug that was creating Groups without a valid group creator being set. See #5983 for related changes.

A few tests are counting the number of users in specific circumstances, so those eight tests have been individually updated so that they pass a valid creator_id without us having to refactor the entire test.

The test_group_has_no_members test has also been removed as it is impossible for a group to have no members. This test used to work because of this bug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/groups/class-bp-group-member-query.php

    r8958 r9120  
    119119
    120120    public function test_with_group_role_admin() {
    121         $g = $this->factory->group->create();
    122         $u1 = $this->create_user();
    123         $u2 = $this->create_user();
    124         $u3 = $this->create_user();
     121        $u1 = $this->create_user();
     122        $u2 = $this->create_user();
     123        $u3 = $this->create_user();
     124        $g  = $this->factory->group->create( array(
     125            'creator_id' => $u1
     126        ) );
    125127        $time = time();
    126128
     
    169171
    170172    public function test_with_group_role_member_admin() {
    171         $g = $this->factory->group->create();
    172         $u1 = $this->create_user();
    173         $u2 = $this->create_user();
    174         $u3 = $this->create_user();
     173        $u1 = $this->create_user();
     174        $u2 = $this->create_user();
     175        $u3 = $this->create_user();
     176        $g  = $this->factory->group->create( array(
     177            'creator_id' => $u1,
     178        ) );
    175179        $time = time();
    176180
     
    194198
    195199    public function test_with_group_role_mod_admin() {
    196         $g = $this->factory->group->create();
    197         $u1 = $this->create_user();
    198         $u2 = $this->create_user();
    199         $u3 = $this->create_user();
     200        $u1 = $this->create_user();
     201        $u2 = $this->create_user();
     202        $u3 = $this->create_user();
     203        $g  = $this->factory->group->create( array(
     204            'creator_id' => $u1,
     205        ) );
    200206        $time = time();
    201207
     
    219225
    220226    public function test_with_group_role_member_mod_admin() {
    221         $g = $this->factory->group->create();
    222         $u1 = $this->create_user();
    223         $u2 = $this->create_user();
    224         $u3 = $this->create_user();
     227        $u1 = $this->create_user();
     228        $u2 = $this->create_user();
     229        $u3 = $this->create_user();
     230        $g  = $this->factory->group->create( array(
     231            'creator_id' => $u1,
     232        ) );
    225233        $time = time();
    226234
     
    244252
    245253    public function test_with_group_role_member_mod_admin_banned() {
    246         $g = $this->factory->group->create();
    247254        $u1 = $this->create_user();
    248255        $u2 = $this->create_user();
    249256        $u3 = $this->create_user();
    250257        $u4 = $this->create_user();
     258        $g  = $this->factory->group->create( array(
     259            'creator_id' => $u1,
     260        ) );
    251261        $time = time();
    252262
     
    294304        $ids = wp_parse_id_list( array_keys( $query_members->results ) );
    295305        $this->assertEquals( array( $u1, ), $ids );
    296     }
    297 
    298     public function test_group_has_no_members() {
    299         $g = $this->factory->group->create();
    300         $u1 = $this->create_user();
    301 
    302         $query_members = new BP_Group_Member_Query( array(
    303             'group_id' => $g,
    304             'group_role' => array( 'member', 'mod', 'admin' ),
    305         ) );
    306 
    307         $ids = wp_parse_id_list( array_keys( $query_members->results ) );
    308         $this->assertEquals( array(), $ids );
    309306    }
    310307
Note: See TracChangeset for help on using the changeset viewer.