Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/20/2017 12:19:36 AM (9 years ago)
Author:
dcavins
Message:

Add 'status' parameter to BP_Groups_Group::get().

Add $status parameter to groups_get_groups()` and its underlying
function BP_Groups_Group::get(). Find groups by passing a single
status, a comma-separated list of statuses, or any array of statuses.

Fixes #7501.

File:
1 edited

Legend:

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

    r11526 r11532  
    21172117        }
    21182118
     2119        /**
     2120         * @group get_by_status
     2121         */
     2122        public function test_get_by_status() {
     2123                $g1 = $this->factory->group->create(array(
     2124                        'status'      => 'private'
     2125                ) );
     2126                $g2 = $this->factory->group->create( array(
     2127                        'status'      => 'public'
     2128                ) );
     2129                $g3 = $this->factory->group->create( array(
     2130                        'status'      => 'hidden'
     2131                ) );
     2132
     2133                $groups = BP_Groups_Group::get( array(
     2134                        'status' => array( 'private', 'hidden' ),
     2135                ) );
     2136
     2137                $found = wp_list_pluck( $groups['groups'], 'id' );
     2138                $this->assertEqualSets( array( $g1, $g3 ), $found );
     2139        }
     2140
     2141        /**
     2142         * @group get_by_status
     2143         */
     2144        public function test_get_by_status_accept_string() {
     2145                $g1 = $this->factory->group->create(array(
     2146                        'status'      => 'private'
     2147                ) );
     2148                $g2 = $this->factory->group->create( array(
     2149                        'status'      => 'public'
     2150                ) );
     2151                $g3 = $this->factory->group->create( array(
     2152                        'status'      => 'hidden'
     2153                ) );
     2154
     2155                $groups = BP_Groups_Group::get( array(
     2156                        'status' => 'public',
     2157                ) );
     2158
     2159                $found = wp_list_pluck( $groups['groups'], 'id' );
     2160                $this->assertEqualSets( array( $g2 ), $found );
     2161        }
     2162
     2163        /**
     2164         * @group get_by_status
     2165         */
     2166        public function test_get_by_status_accept_comma_separated_string() {
     2167                $g1 = $this->factory->group->create(array(
     2168                        'status'      => 'private'
     2169                ) );
     2170                $g2 = $this->factory->group->create( array(
     2171                        'status'      => 'public'
     2172                ) );
     2173                $g3 = $this->factory->group->create( array(
     2174                        'status'      => 'hidden'
     2175                ) );
     2176
     2177                $groups = BP_Groups_Group::get( array(
     2178                        'status' => 'private, hidden',
     2179                ) );
     2180
     2181                $found = wp_list_pluck( $groups['groups'], 'id' );
     2182                $this->assertEqualSets( array( $g1, $g3 ), $found );
     2183        }
     2184
    21192185}
    21202186
Note: See TracChangeset for help on using the changeset viewer.