You are here

protected function IsGroupMemberCacheContextTest::createGroupMembershipLoader in Group 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Unit/IsGroupMemberCacheContextTest.php \Drupal\Tests\group\Unit\IsGroupMemberCacheContextTest::createGroupMembershipLoader()

Creates a GroupMembershipLoaderInterface prophecy.

Parameters

bool $is_member: Whether this will find the member or not.

Return value

\Prophecy\Prophecy\ObjectProphecy The prophesized group membership loader.

File

tests/src/Unit/IsGroupMemberCacheContextTest.php, line 180

Class

IsGroupMemberCacheContextTest
Tests the user.is_group_member:%group_id cache context.

Namespace

Drupal\Tests\group\Unit

Code

protected function createGroupMembershipLoader($is_member) {
  $prophecy = $this
    ->prophesize(GroupMembershipLoaderInterface::class);
  $return = $is_member ? $this
    ->prophesize(GroupMembership::class)
    ->reveal() : $is_member;
  $prophecy
    ->load($this->group, $this->currentUser)
    ->willReturn($return);
  return $prophecy;
}