Skip to:
Content

BuddyPress.org

Ticket #6193: 6193.unittests.patch

File 6193.unittests.patch, 2.2 KB (added by imath, 5 years ago)
  • tests/phpunit/testcases/core/class-bp-user-query.php

    diff --git tests/phpunit/testcases/core/class-bp-user-query.php tests/phpunit/testcases/core/class-bp-user-query.php
    index bf63311..1099d76 100644
    class BP_Tests_BP_User_Query_TestCases extends BP_UnitTestCase { 
    514514                        'include' => $users,
    515515                ) );
    516516
    517                 $this->assertSame( 'foo', wp_cache_get( $users[0], 'bp_member_type' ) );
    518                 $this->assertSame( 'bar', wp_cache_get( $users[1], 'bp_member_type' ) );
    519                 $this->assertSame( 'foo', wp_cache_get( $users[2], 'bp_member_type' ) );
     517                $this->assertSame( array( 'foo' ), wp_cache_get( $users[0], 'bp_member_type' ) );
     518                $this->assertSame( array( 'bar' ), wp_cache_get( $users[1], 'bp_member_type' ) );
     519                $this->assertSame( array( 'foo' ), wp_cache_get( $users[2], 'bp_member_type' ) );
    520520                $this->assertSame( '', wp_cache_get( $users[3], 'bp_member_type' ) );
    521521        }
    522522}
  • tests/phpunit/testcases/members/types.php

    diff --git tests/phpunit/testcases/members/types.php tests/phpunit/testcases/members/types.php
    index fd14d1e..de047a0 100644
    class BP_Tests_Members_Types extends BP_UnitTestCase { 
    162162        }
    163163
    164164        /**
     165         * @group BP6193
     166         */
     167        public function test_bp_members_prefetch_member_type_array_cache_set() {
     168                $u1 = $this->factory->user->create();
     169                $u2 = $this->factory->user->create();
     170                bp_register_member_type( 'foo' );
     171                bp_register_member_type( 'bar' );
     172                bp_set_member_type( $u1, 'foo' );
     173                bp_set_member_type( $u1, 'bar', true );
     174
     175                // Get users so that the 'bp_user_query_populate_extras' is fired
     176                // and members type prefetched
     177                $users = bp_core_get_users( array( 'include' => array( $u1, $u2 ) ) );
     178
     179                // Get single member type
     180                $this->assertSame( 'foo', bp_get_member_type( $u1, true ) );
     181                $this->assertEmpty( bp_get_member_type( $u2, true ) );
     182
     183                // Get all member types for the user
     184                $this->assertEqualSets( array( 'foo', 'bar' ), bp_get_member_type( $u1, false ) );
     185                $this->assertEmpty( bp_get_member_type( $u2, false ) );
     186        }
     187
     188        /**
    165189         * @group cache
    166190         */
    167191        public function test_bp_get_member_type_should_return_false_for_deleted_user() {