Skip to:
Content

BuddyPress.org

Changeset 7050


Ignore:
Timestamp:
05/09/2013 02:22:04 PM (11 years ago)
Author:
boonebgorges
Message:

In test suite, factory->group->create() should return an id, not an object

For better parity with other factories

Location:
trunk/tests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/includes/factory.php

    r7047 r7050  
    7676        groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
    7777
    78         return $this->get_object_by_id( $group_id );
     78        return $group_id;
    7979    }
    8080
  • trunk/tests/testcases/groups/class-bp-groups-group.php

    r7038 r7050  
    2929        $g1 = $this->factory->group->create();
    3030        $g2 = $this->factory->group->create();
    31         groups_update_groupmeta( $g1->id, 'foo', 'bar' );
     31        groups_update_groupmeta( $g1, 'foo', 'bar' );
    3232
    3333        $groups = BP_Groups_Group::get( array(
    3434            'exclude' => array(
    35                 $g1->id,
     35                $g1,
    3636                'foobar',
    3737            ),
    3838        ) );
    3939        $ids = wp_list_pluck( $groups['groups'], 'id' );
    40         $this->assertEquals( $ids, array( $g2->id ) );
     40        $this->assertEquals( $ids, array( $g2 ) );
    4141    }
    4242
     
    4444        $g1 = $this->factory->group->create();
    4545        $g2 = $this->factory->group->create();
    46         groups_update_groupmeta( $g1->id, 'foo', 'bar' );
     46        groups_update_groupmeta( $g1, 'foo', 'bar' );
    4747
    4848        $groups = BP_Groups_Group::get( array(
    4949            'include' => array(
    50                 $g1->id,
     50                $g1,
    5151                'foobar',
    5252            ),
    5353        ) );
    5454        $ids = wp_list_pluck( $groups['groups'], 'id' );
    55         $this->assertEquals( $ids, array( $g1->id ) );
     55        $this->assertEquals( $ids, array( $g1 ) );
    5656    }
    5757
     
    5959        $g1 = $this->factory->group->create();
    6060        $g2 = $this->factory->group->create();
    61         groups_update_groupmeta( $g1->id, 'foo', 'bar' );
     61        groups_update_groupmeta( $g1, 'foo', 'bar' );
    6262
    6363        $groups = BP_Groups_Group::get( array(
     
    7070        ) );
    7171        $ids = wp_list_pluck( $groups['groups'], 'id' );
    72         $this->assertEquals( $ids, array( $g1->id ) );
     72        $this->assertEquals( $ids, array( $g1 ) );
    7373    }
    7474
     
    7676        $g1 = $this->factory->group->create();
    7777        $g2 = $this->factory->group->create();
    78         groups_update_groupmeta( $g1->id, 'foo', 'bar' );
     78        groups_update_groupmeta( $g1, 'foo', 'bar' );
    7979
    8080        $groups = BP_Groups_Group::get( array(
     
    8282        ) );
    8383        $ids = wp_list_pluck( $groups['groups'], 'id' );
    84         $this->assertEquals( $ids, array( $g1->id, $g2->id, ) );
     84        $this->assertEquals( $ids, array( $g1, $g2, ) );
    8585    }
    8686
     
    9797
    9898        $found = wp_list_pluck( $groups['groups'], 'id' );
    99         $this->assertEquals( array( $g1->id ), $found );
     99        $this->assertEquals( array( $g1 ), $found );
    100100    }
    101101
     
    112112
    113113        $found = wp_list_pluck( $groups['groups'], 'id' );
    114         $this->assertEquals( array( $g1->id ), $found );
     114        $this->assertEquals( array( $g1 ), $found );
    115115    }
    116116
     
    127127
    128128        $found = wp_list_pluck( $groups['groups'], 'id' );
    129         $this->assertEquals( array( $g1->id ), $found );
     129        $this->assertEquals( array( $g1 ), $found );
    130130    }
    131131
     
    143143        $found = wp_list_pluck( $groups['groups'], 'id' );
    144144
    145         // @todo
    146         $this->assertEquals( array( $g1->id ), $found );
     145        $this->assertEquals( array( $g1 ), $found );
    147146    }
    148147
     
    154153        $g2 = $this->factory->group->create();
    155154        $u = $this->factory->user->create();
    156         self::add_user_to_group( $u, $g1->id );
     155        self::add_user_to_group( $u, $g1 );
    157156
    158157        $groups = BP_Groups_Group::filter_user_groups( 'Cool', $u );
    159158
    160159        $found = wp_list_pluck( $groups['groups'], 'group_id' );
    161         $this->assertEquals( array( $g1->id ), $found );
     160        $this->assertEquals( array( $g1 ), $found );
    162161    }
    163162
     
    170169
    171170        $u = $this->factory->user->create();
    172         self::add_user_to_group( $u, $g1->id );
    173         self::add_user_to_group( $u, $g2->id );
     171        self::add_user_to_group( $u, $g1 );
     172        self::add_user_to_group( $u, $g2 );
    174173
    175174        $groups = BP_Groups_Group::filter_user_groups( '_cool_', $u );
    176175
    177176        $found = wp_list_pluck( $groups['groups'], 'group_id' );
    178         $this->assertEquals( array( $g1->id ), $found );
     177        $this->assertEquals( array( $g1 ), $found );
    179178    }
    180179
     
    187186
    188187        $u = $this->factory->user->create();
    189         self::add_user_to_group( $u, $g1->id );
    190         self::add_user_to_group( $u, $g2->id );
     188        self::add_user_to_group( $u, $g1 );
     189        self::add_user_to_group( $u, $g2 );
    191190
    192191        $groups = BP_Groups_Group::filter_user_groups( '100%', $u );
    193192
    194193        $found = wp_list_pluck( $groups['groups'], 'group_id' );
    195         $this->assertEquals( array( $g1->id ), $found );
     194        $this->assertEquals( array( $g1 ), $found );
    196195    }
    197196
     
    204203
    205204        $u = $this->factory->user->create();
    206         self::add_user_to_group( $u, $g1->id );
    207         self::add_user_to_group( $u, $g2->id );
     205        self::add_user_to_group( $u, $g1 );
     206        self::add_user_to_group( $u, $g2 );
    208207
    209208        $groups = BP_Groups_Group::filter_user_groups( "'tis ", $u );
     
    225224
    226225        $found = wp_list_pluck( $groups['groups'], 'group_id' );
    227         $this->assertEquals( array( $g1->id ), $found );
     226        $this->assertEquals( array( $g1 ), $found );
    228227    }
    229228
     
    238237
    239238        $found = wp_list_pluck( $groups['groups'], 'group_id' );
    240         $this->assertEquals( array( $g1->id ), $found );
     239        $this->assertEquals( array( $g1 ), $found );
    241240    }
    242241
     
    251250
    252251        $found = wp_list_pluck( $groups['groups'], 'group_id' );
    253         $this->assertEquals( array( $g1->id ), $found );
     252        $this->assertEquals( array( $g1 ), $found );
    254253    }
    255254
     
    265264        $found = wp_list_pluck( $groups['groups'], 'group_id' );
    266265
    267         $this->assertEquals( array( $g1->id ), $found );
     266        $this->assertEquals( array( $g1 ), $found );
    268267    }
    269268
     
    278277        ) );
    279278
    280         $groups = BP_Groups_Group::get_by_letter( 'A', null, null, true, array( $g1->id, 'stringthatshouldberemoved' ) );
    281 
    282         $found = wp_list_pluck( $groups['groups'], 'id' );
    283 
    284         $this->assertEquals( array( $g2->id ), $found );
     279        $groups = BP_Groups_Group::get_by_letter( 'A', null, null, true, array( $g1, 'stringthatshouldberemoved' ) );
     280
     281        $found = wp_list_pluck( $groups['groups'], 'id' );
     282
     283        $this->assertEquals( array( $g2 ), $found );
    285284
    286285    }
     
    310309
    311310        // There are only two groups, so excluding one should give us the other
    312         $groups = BP_Groups_Group::get_random( null, null, 0, false, true, array( $g1->id, 'ignore this' ) );
    313 
    314         $found = wp_list_pluck( $groups['groups'], 'id' );
    315 
    316         $this->assertEquals( array( $g2->id ), $found );
     311        $groups = BP_Groups_Group::get_random( null, null, 0, false, true, array( $g1, 'ignore this' ) );
     312
     313        $found = wp_list_pluck( $groups['groups'], 'id' );
     314
     315        $this->assertEquals( array( $g2 ), $found );
    317316    }
    318317
     
    330329        $found = wp_list_pluck( $groups['groups'], 'id' );
    331330
    332         $this->assertEquals( array( $g1->id ), $found );
     331        $this->assertEquals( array( $g1 ), $found );
    333332    }
    334333}
  • trunk/tests/testcases/groups/class-bp-groups-member.php

    r7015 r7050  
    4848
    4949        $u = $this->factory->user->create();
    50         self::add_user_to_group( $u, $g1->id );
    51         self::add_user_to_group( $u, $g2->id );
     50        self::add_user_to_group( $u, $g1 );
     51        self::add_user_to_group( $u, $g2 );
    5252
    5353        $groups = BP_Groups_Member::get_recently_joined( $u, false, false, 'Rite' );
    5454
    5555        $ids = wp_list_pluck( $groups['groups'], 'id' );
    56         $this->assertEquals( $ids, array( $g2->id ) );
     56        $this->assertEquals( $ids, array( $g2 ) );
    5757    }
    5858
     
    6666
    6767        $u = $this->factory->user->create();
    68         self::add_user_to_group( $u, $g1->id );
    69         self::add_user_to_group( $u, $g2->id );
     68        self::add_user_to_group( $u, $g1 );
     69        self::add_user_to_group( $u, $g2 );
    7070
    71         $m1 = new BP_Groups_Member( $u, $g1->id );
     71        $m1 = new BP_Groups_Member( $u, $g1 );
    7272        $m1->promote( 'admin' );
    73         $m2 = new BP_Groups_Member( $u, $g2->id );
     73        $m2 = new BP_Groups_Member( $u, $g2 );
    7474        $m2->promote( 'admin' );
    7575
     
    7777
    7878        $ids = wp_list_pluck( $groups['groups'], 'id' );
    79         $this->assertEquals( $ids, array( $g2->id ) );
     79        $this->assertEquals( $ids, array( $g2 ) );
    8080    }
    8181
     
    8989
    9090        $u = $this->factory->user->create();
    91         self::add_user_to_group( $u, $g1->id );
    92         self::add_user_to_group( $u, $g2->id );
     91        self::add_user_to_group( $u, $g1 );
     92        self::add_user_to_group( $u, $g2 );
    9393
    94         $m1 = new BP_Groups_Member( $u, $g1->id );
     94        $m1 = new BP_Groups_Member( $u, $g1 );
    9595        $m1->promote( 'mod' );
    96         $m2 = new BP_Groups_Member( $u, $g2->id );
     96        $m2 = new BP_Groups_Member( $u, $g2 );
    9797        $m2->promote( 'mod' );
    9898
     
    100100
    101101        $ids = wp_list_pluck( $groups['groups'], 'id' );
    102         $this->assertEquals( $ids, array( $g2->id ) );
     102        $this->assertEquals( $ids, array( $g2 ) );
    103103    }
    104104
     
    113113        $u1 = $this->factory->user->create();
    114114        $u2 = $this->factory->user->create();
    115         self::add_user_to_group( $u1, $g1->id );
    116         self::add_user_to_group( $u1, $g2->id );
    117         self::invite_user_to_group( $u2, $g1->id, $u1 );
    118         self::invite_user_to_group( $u2, $g2->id, $u1 );
     115        self::add_user_to_group( $u1, $g1 );
     116        self::add_user_to_group( $u1, $g2 );
     117        self::invite_user_to_group( $u2, $g1, $u1 );
     118        self::invite_user_to_group( $u2, $g2, $u1 );
    119119
    120         $groups = BP_Groups_Member::get_invites( $u2, false, false, array( 'awesome', $g1->id ) );
     120        $groups = BP_Groups_Member::get_invites( $u2, false, false, array( 'awesome', $g1 ) );
    121121
    122122        $ids = wp_list_pluck( $groups['groups'], 'id' );
    123         $this->assertEquals( $ids, array( $g2->id ) );
     123        $this->assertEquals( $ids, array( $g2 ) );
    124124    }
    125125
     
    129129        $u1 = $this->create_user();
    130130        $u2 = $this->create_user();
    131         self::add_user_to_group( $u1, $g1->id );
    132         self::add_user_to_group( $u2, $g1->id );
     131        self::add_user_to_group( $u1, $g1 );
     132        self::add_user_to_group( $u2, $g1 );
    133133
    134         $members = BP_Groups_Member::get_all_for_group( $g1->id, false, false, true, true, array( $u1 ) );
     134        $members = BP_Groups_Member::get_all_for_group( $g1, false, false, true, true, array( $u1 ) );
    135135
    136136        $mm = (array) $members['members'];
  • trunk/tests/testcases/groups/template.php

    r6950 r7050  
    1515        $g1 = $this->factory->group->create();
    1616        $g2 = $this->factory->group->create();
    17         groups_update_groupmeta( $g1->id, 'foo', 'bar' );
     17        groups_update_groupmeta( $g1, 'foo', 'bar' );
    1818
    1919        global $groups_template;
     
    2828
    2929        $ids = wp_list_pluck( $groups_template->groups, 'id' );
    30         $this->assertEquals( $ids, array( $g1->id, ) );
     30        $this->assertEquals( $ids, array( $g1, ) );
    3131    }
    3232}
Note: See TracChangeset for help on using the changeset viewer.