Skip to:
Content

BuddyPress.org


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

File:
1 edited

Legend:

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