Skip to:
Content

BuddyPress.org

Ticket #9000: 9000.unittests.patch

File 9000.unittests.patch, 1.9 KB (added by imath, 2 years ago)
  • tests/phpunit/testcases/groups/cache.php

    diff --git tests/phpunit/testcases/groups/cache.php tests/phpunit/testcases/groups/cache.php
    index 002fd16b0..98516c134 100644
     
    55 * @group cache
    66 */
    77class BP_Tests_Group_Cache extends BP_UnitTestCase {
     8
    89        /**
    910         * @group bp_groups_update_meta_cache
    1011         */
    class BP_Tests_Group_Cache extends BP_UnitTestCase { 
    279280                $this->assertEquals( 3, groups_get_total_group_count( true ) );
    280281                $this->assertEquals( 3, BP_Groups_Group::get_total_group_count() );
    281282        }
     283
     284        /**
     285         * @ticket BP9000
     286         */
     287        public function test_groups_get_groups_for_user_cache_once_left() {
     288                $g = self::factory()->group->create();
     289                $u = self::factory()->user->create();
     290
     291                groups_join_group( $g, $u );
     292                $u_groups = groups_get_groups( array( 'user_id' => $u ) );
     293                $u_group_ids = wp_list_pluck( $u_groups['groups'], 'id' );
     294
     295                $this->assertContains( $g, $u_group_ids );
     296
     297                groups_leave_group( $g, $u );
     298                $u_groups = groups_get_groups( array( 'user_id' => $u ) );
     299                $u_group_ids = wp_list_pluck( $u_groups['groups'], 'id' );
     300
     301                $this->assertNotContains( $g, $u_group_ids );
     302        }
     303
     304        /**
     305         * @ticket BP9000
     306         */
     307        public function test_groups_get_groups_for_user_cache_once_removed() {
     308                $g = self::factory()->group->create();
     309                $u = self::factory()->user->create();
     310
     311                groups_join_group( $g, $u );
     312                $u_groups = groups_get_groups( array( 'user_id' => $u ) );
     313                $u_group_ids = wp_list_pluck( $u_groups['groups'], 'id' );
     314
     315                $this->assertContains( $g, $u_group_ids );
     316
     317                add_filter( 'bp_is_item_admin', '__return_true' );
     318                groups_remove_member( $u, $g );
     319                remove_filter( 'bp_is_item_admin', '__return_true' );
     320
     321                $u_groups = groups_get_groups( array( 'user_id' => $u ) );
     322                $u_group_ids = wp_list_pluck( $u_groups['groups'], 'id' );
     323
     324                $this->assertNotContains( $g, $u_group_ids );
     325        }
    282326}