Skip to:
Content

BuddyPress.org

Changeset 7274


Ignore:
Timestamp:
07/16/2013 07:31:01 PM (13 years ago)
Author:
boonebgorges
Message:

Adds unit test for #5099

This tests whether the total group count return by BP_Groups_Group::get() is
correctly calculated when using meta_query

See #5099

Props r-a-y

File:
1 edited

Legend:

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

    r7134 r7274  
    6262        /**
    6363         * @group get
     64         * @group group_meta_query
    6465         */
    6566        public function test_get_with_meta_query() {
    … …  
    8283        /**
    8384         * @group get
     85         * @group group_meta_query
    8486         */
    8587        public function test_get_empty_meta_query() {
    … …  
    253255                $found = wp_parse_id_list( wp_list_pluck( $groups['groups'], 'id' ) );
    254256                $this->assertEquals( array( $g2, $g4, $g3, $g1 ), $found );
     257        }
     258
     259        /**
     260         * @group get
     261         * @group group_meta_query
     262         * @ticket BP5099
     263         */
     264        public function test_meta_query_and_total_groups() {
     265                $g1 = $this->factory->group->create( array(
     266                        'name' => 'A Group',
     267                        'date_created' => bp_core_current_time(),
     268                ) );
     269                $g2 = $this->factory->group->create( array(
     270                        'name' => 'D Group',
     271                        'date_created' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
     272                ) );
     273                $g3 = $this->factory->group->create( array(
     274                        'name' => 'B Group',
     275                        'date_created' => gmdate( 'Y-m-d H:i:s', $time - 100000 ),
     276                ) );
     277                $g4 = $this->factory->group->create( array(
     278                        'name' => 'C Group',
     279                        'date_created' => gmdate( 'Y-m-d H:i:s', $time - 1000 ),
     280                ) );
     281
     282                // mark one group with the metakey 'supergroup'
     283                groups_update_groupmeta( $g1, 'supergroup', 1 );
     284
     285                // fetch groups with our 'supergroup' metakey
     286                $groups = BP_Groups_Group::get( array(
     287                        'meta_query' => array(
     288                                array(
     289                                        'key'     => 'supergroup',
     290                                        'compare' => 'EXISTS',
     291                                )
     292                        )
     293                ) );
     294
     295                // group total should match 1
     296                $this->assertEquals( '1', $groups['total'] );
    255297        }
    256298
Note: See TracChangeset for help on using the changeset viewer.