create_user(); $u2 = $this->create_user(); $g = $this->factory->group->create( array( 'creator_id' => $u1 ) ); groups_join_group( $g, $u2 ); $this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) ); } /** * @group total_group_count * @group groups_leave_group */ public function test_total_group_count_groups_leave_group() { $u1 = $this->create_user(); $u2 = $this->create_user(); $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); $g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); groups_join_group( $g1, $u2 ); groups_join_group( $g2, $u2 ); groups_leave_group( $g1, $u2 ); $this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) ); } /** * @group total_group_count * @group groups_ban_member */ public function test_total_group_count_groups_ban_member() { $u1 = $this->create_user(); $u2 = $this->create_user(); $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); $g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); groups_join_group( $g1, $u2 ); groups_join_group( $g2, $u2 ); // Fool the admin check $this->set_current_user( $u1 ); buddypress()->is_item_admin = true; groups_ban_member( $u2, $g1 ); $this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) ); } /** * @group total_group_count * @group groups_unban_member */ public function test_total_group_count_groups_unban_member() { $u1 = $this->create_user(); $u2 = $this->create_user(); $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); $g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); groups_join_group( $g1, $u2 ); groups_join_group( $g2, $u2 ); // Fool the admin check $this->set_current_user( $u1 ); buddypress()->is_item_admin = true; groups_ban_member( $u2, $g1 ); groups_unban_member( $u2, $g1 ); $this->assertEquals( 2, bp_get_user_meta( $u2, 'total_group_count', true ) ); } /** * @group total_group_count * @group groups_accept_invite */ public function test_total_group_count_groups_accept_invite() { $u1 = $this->create_user(); $u2 = $this->create_user(); $g = $this->factory->group->create(); groups_invite_user( array( 'user_id' => $u1, 'group_id' => $g, 'inviter_id' => $u2, ) ); groups_accept_invite( $u2, $g ); $this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) ); } /** * @group total_group_count * @group groups_accept_membership_request */ public function test_total_group_count_groups_accept_membership_request() { $u = $this->create_user(); $g = $this->factory->group->create(); groups_send_membership_request( $u, $g ); groups_accept_membership_request( 0, $u, $g ); $this->assertEquals( 1, bp_get_user_meta( $u, 'total_group_count', true ) ); } /** * @group total_group_count * @group groups_remove_member */ public function test_total_group_count_groups_remove_member() { $u1 = $this->create_user(); $u2 = $this->create_user(); $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); $g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); groups_join_group( $g1, $u2 ); groups_join_group( $g2, $u2 ); // Fool the admin check $this->set_current_user( $u1 ); buddypress()->is_item_admin = true; groups_remove_member( $u2, $g1 ); $this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) ); } /** * @group total_member_count * @group groups_join_group */ public function test_total_member_count_groups_join_group() { $u1 = $this->create_user(); $u2 = $this->create_user(); $g = $this->factory->group->create( array( 'creator_id' => $u1 ) ); groups_join_group( $g, $u2 ); $this->assertEquals( 2, groups_get_groupmeta( $g, 'total_member_count' ) ); } /** * @group total_member_count * @group groups_leave_group */ public function test_total_member_count_groups_leave_group() { $u1 = $this->create_user(); $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); groups_join_group( $g1, $u2 ); groups_leave_group( $g1, $u2 ); $this->assertEquals( 1, groups_get_groupmeta( $g1, 'total_member_count' ) ); } /** * @group total_member_count * @group groups_ban_member */ public function test_total_member_count_groups_ban_member() { $u1 = $this->create_user(); $u2 = $this->create_user(); $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); groups_join_group( $g1, $u2 ); // Fool the admin check $this->set_current_user( $u1 ); buddypress()->is_item_admin = true; groups_ban_member( $u2, $g1 ); $this->assertEquals( 1, groups_get_groupmeta( $g1, 'total_member_count' ) ); } /** * @group total_member_count * @group groups_unban_member */ public function test_total_member_count_groups_unban_member() { $u1 = $this->create_user(); $u2 = $this->create_user(); $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); groups_join_group( $g1, $u2 ); // Fool the admin check $this->set_current_user( $u1 ); buddypress()->is_item_admin = true; groups_ban_member( $u2, $g1 ); groups_unban_member( $u2, $g1 ); $this->assertEquals( 2, groups_get_groupmeta( $g1, 'total_member_count' ) ); } /** * @group total_member_count * @group groups_accept_invite */ public function test_total_member_count_groups_accept_invite() { $u1 = $this->create_user(); $u2 = $this->create_user(); $g = $this->factory->group->create( array( 'creator_id' => $u1 ) ); groups_invite_user( array( 'user_id' => $u1, 'group_id' => $g, 'inviter_id' => $u2, ) ); groups_accept_invite( $u2, $g ); $this->assertEquals( 2, groups_get_groupmeta( $g, 'total_member_count' ) ); } /** * @group total_member_count * @group groups_accept_membership_request */ public function test_total_member_count_groups_accept_membership_request() { $u1 = $this->create_user(); $u2 = $this->create_user(); $g = $this->factory->group->create( array( 'creator_id' => $u1 ) ); groups_send_membership_request( $u2, $g ); groups_accept_membership_request( 0, $u2, $g ); $this->assertEquals( 2, groups_get_groupmeta( $g, 'total_member_count' ) ); } /** * @group total_member_count * @group groups_remove_member */ public function test_total_member_count_groups_remove_member() { $u1 = $this->create_user(); $u2 = $this->create_user(); $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); groups_join_group( $g1, $u2 ); // Fool the admin check $this->set_current_user( $u1 ); buddypress()->is_item_admin = true; groups_remove_member( $u2, $g1 ); $this->assertEquals( 1, groups_get_groupmeta( $g1, 'total_member_count' ) ); } /** * @group total_member_count * @group groups_create_group */ public function test_total_member_count_groups_create_group() { $u1 = $this->create_user(); $g = groups_create_group( array( 'creator_id' => $u1, 'name' => 'Boone Is Handsome', 'description' => 'Yes', 'slug' => 'boone-is-handsome', 'status' => 'public', 'enable_forum' => 0, 'date_created' => bp_core_current_time(), ) ); $this->assertEquals( 1, groups_get_groupmeta( $g, 'total_member_count' ) ); } }