Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/07/2015 08:34:31 PM (12 years ago)
Author:
boonebgorges
Message:

When prefetching member types in the loop, cache arrays instead of strings.

Member type caches should always be arrays of all member types for a user.

Props imath.
Fixes #6193 for the 2.2 branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/tests/phpunit/testcases/members/types.php

    r9371 r9448  
    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         */
Note: See TracChangeset for help on using the changeset viewer.