You are here

public function IsGroupMemberCacheContextTest::testGetContextWithInvalidGroupId in Group 8

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

Tests getting the context value while specifying a non-existent group.

@covers ::getContext

File

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

Class

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

Namespace

Drupal\Tests\group\Unit

Code

public function testGetContextWithInvalidGroupId() {
  $cache_context = new IsGroupMemberCacheContext($this->currentUser, $this
    ->createEntityTypeManager(1)
    ->reveal(), $this
    ->createGroupMembershipLoader(FALSE)
    ->reveal());
  $this
    ->expectException(\LogicException::class);
  $this
    ->expectExceptionMessage('Incorrect group ID provided for user.is_group_member cache context.');
  $cache_context
    ->getContext(2);
}