Skip to:
Content

BuddyPress.org

Ticket #5824: 5824.unit_test.02.patch

File 5824.unit_test.02.patch, 1.4 KB (added by imath, 10 years ago)
  • tests/phpunit/testcases/groups/class-bp-groups-group.php

    diff --git tests/phpunit/testcases/groups/class-bp-groups-group.php tests/phpunit/testcases/groups/class-bp-groups-group.php
    index 826fa83..2b77772 100644
    class BP_Tests_BP_Groups_Group_TestCases extends BP_UnitTestCase { 
    136136
    137137        /**
    138138         * @group get
     139         * @group group_meta_query
     140         * @ticket BP5824
     141         */
     142        public function test_get_with_meta_query_multiple_keys_with_same_value() {
     143                $now = time();
     144                $g1 = $this->factory->group->create( array(
     145                        'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60 ),
     146                ) );
     147                $g2 = $this->factory->group->create( array(
     148                        'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60*2 ),
     149                ) );
     150                groups_update_groupmeta( $g1, 'foo', 'bar' );
     151                groups_update_groupmeta( $g2, 'foo', 'b' );
     152                groups_update_groupmeta( $g2, 'foo2', 'bar' );
     153
     154                $groups = BP_Groups_Group::get( array(
     155                        'meta_query' => array(
     156                                'relation' => 'AND',
     157                                array(
     158                                        'key' => 'foo',
     159                                        'value' => 'bar',
     160                                        'compare' => '='
     161                                ),
     162                        ),
     163                ) );
     164                $ids = wp_list_pluck( $groups['groups'], 'id' );
     165                $this->assertEquals( $ids, array( $g1 ) );
     166                $this->assertEquals( 1, $groups['total'] );
     167        }
     168
     169        /**
     170         * @group get
    139171         */
    140172        public function test_get_normal_search() {
    141173                $g1 = $this->factory->group->create( array(