You are here

protected function OgMembershipStateCacheContextTest::expectMembership in Organic groups 8

Sets an expectation that the current user has the given membership state.

Parameters

string|false $state: The membership state, or FALSE if the user is not a member.

1 call to OgMembershipStateCacheContextTest::expectMembership()
OgMembershipStateCacheContextTest::setupExpectedContext in tests/src/Unit/Cache/Context/OgMembershipStateCacheContextTest.php
Set up expectations for tests that have an active context object.

File

tests/src/Unit/Cache/Context/OgMembershipStateCacheContextTest.php, line 83

Class

OgMembershipStateCacheContextTest
Tests OG membership state cache context.

Namespace

Drupal\Tests\og\Unit\Cache\Context

Code

protected function expectMembership($state) {

  // If the user is a member, it is expected that the membership state will be
  // retrieved.
  if ($state) {
    $this->membership
      ->getState()
      ->willReturn($state);
    $state = $this->membership;
  }

  // It is expected that the user membership will be retrieved, of any
  // possible membership state.
  $states = [
    OgMembershipInterface::STATE_ACTIVE,
    OgMembershipInterface::STATE_PENDING,
    OgMembershipInterface::STATE_BLOCKED,
  ];
  $this->membershipManager
    ->getMembership($this->group
    ->reveal(), $this->user
    ->reveal()
    ->id(), $states)
    ->willReturn($state);
}