Skip to:
Content

BuddyPress.org

Changeset 9300


Ignore:
Timestamp:
01/06/2015 03:38:23 AM (6 years ago)
Author:
r-a-y
Message:

Tests: Add tests for non-members for bp_groups_user_can_send_invites()

Props dcavins.

See #6031.

File:
1 edited

Legend:

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

    r9293 r9300  
    133133     */
    134134    public function test_bp_groups_user_can_send_invites() {
     135        $u_nonmembers = $this->factory->user->create();
    135136        $u_members = $this->factory->user->create();
    136137        $u_mods = $this->factory->user->create();
     
    165166        // In bp_group_get_invite_status(), no status falls back to "members"
    166167        $this->assertTrue( '' == groups_get_groupmeta( $g, 'invite_status' ) );
     168        $this->assertFalse( bp_groups_user_can_send_invites( $g, $u_nonmembers ) );
    167169        $this->assertTrue( bp_groups_user_can_send_invites( $g, $u_members ) );
    168170        $this->assertTrue( bp_groups_user_can_send_invites( $g, $u_mods ) );
     
    172174        // Test with members status
    173175        groups_update_groupmeta( $g, 'invite_status', 'members' );
     176        $this->assertFalse( bp_groups_user_can_send_invites( $g, $u_nonmembers ) );
    174177        $this->assertTrue( bp_groups_user_can_send_invites( $g, $u_members ) );
    175178        $this->assertTrue( bp_groups_user_can_send_invites( $g, $u_mods ) );
     
    182185        // Test with mod status
    183186        groups_update_groupmeta( $g, 'invite_status', 'mods' );
     187        $this->assertFalse( bp_groups_user_can_send_invites( $g, $u_nonmembers ) );
    184188        $this->assertFalse( bp_groups_user_can_send_invites( $g, $u_members ) );
    185189        $this->assertTrue( bp_groups_user_can_send_invites( $g, $u_mods ) );
     
    194198        // Test with admin status
    195199        groups_update_groupmeta( $g, 'invite_status', 'admins' );
     200        $this->assertFalse( bp_groups_user_can_send_invites( $g, $u_nonmembers ) );
    196201        $this->assertFalse( bp_groups_user_can_send_invites( $g, $u_members ) );
    197202        $this->assertFalse( bp_groups_user_can_send_invites( $g, $u_mods ) );
     
    212217        $g_obj = groups_get_group( array( 'group_id' => $g ) );
    213218        $this->go_to( bp_get_group_permalink( $g_obj ) );
    214         groups_update_groupmeta( $g, 'invite_status', 'members' );
    215 
    216         $this->assertTrue( bp_groups_user_can_send_invites( null, $u_members ) );
     219        groups_update_groupmeta( $g, 'invite_status', 'mods' );
     220        $this->assertFalse( bp_groups_user_can_send_invites( null, $u_nonmembers ) );
     221        $this->assertFalse( bp_groups_user_can_send_invites( null, $u_members ) );
     222        $this->assertTrue( bp_groups_user_can_send_invites( null, $u_mods ) );
    217223
    218224        $this->set_current_user( $old_current_user );
Note: See TracChangeset for help on using the changeset viewer.