Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/04/2013 03:04:29 AM (10 years ago)
Author:
boonebgorges
Message:

Deprecate exclude_banned arg of bp_group_has_members() in favor of 'banned' role

This changeset introduces support for the 'banned' group_role filter in
BP_Group_Member_Query. This takes the place of the exclude_banned parameter.
Backward compatibility for exclude_banned is added in
groups_get_group_members().

See #4977

File:
1 edited

Legend:

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

    r7143 r7145  
    223223    }
    224224
     225    public function test_with_group_role_member_mod_admin_banned() {
     226        $g = $this->factory->group->create();
     227        $u1 = $this->create_user();
     228        $u2 = $this->create_user();
     229        $u3 = $this->create_user();
     230        $u4 = $this->create_user();
     231
     232        $this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
     233        $this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
     234        $this->add_user_to_group( $u3, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) );
     235        $this->add_user_to_group( $u4, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) );
     236
     237        $m1 = new BP_Groups_Member( $u1, $g );
     238        $m1->promote( 'admin' );
     239        $m2 = new BP_Groups_Member( $u2, $g );
     240        $m2->promote( 'mod' );
     241        $m3 = new BP_Groups_Member( $u3, $g );
     242        $m3->ban();
     243
     244        $query_members = new BP_Group_Member_Query( array(
     245            'group_id' => $g,
     246            'group_role' => array( 'member', 'mod', 'admin', 'banned' ),
     247        ) );
     248
     249        $ids = wp_parse_id_list( array_keys( $query_members->results ) );
     250        $this->assertEquals( array( $u1, $u2, $u3, $u4, ), $ids );
     251    }
     252
     253    public function test_with_group_role_banned() {
     254        $g = $this->factory->group->create();
     255        $u1 = $this->create_user();
     256        $u2 = $this->create_user();
     257
     258        $this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
     259        $this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
     260
     261        $m1 = new BP_Groups_Member( $u1, $g );
     262        $m1->ban();
     263
     264        $query_members = new BP_Group_Member_Query( array(
     265            'group_id' => $g,
     266            'group_role' => array( 'banned' ),
     267        ) );
     268
     269        $ids = wp_parse_id_list( array_keys( $query_members->results ) );
     270        $this->assertEquals( array( $u1, ), $ids );
     271    }
     272
    225273    public function test_group_has_no_members() {
    226274        $g = $this->factory->group->create();
Note: See TracChangeset for help on using the changeset viewer.