You are here

public function GroupPermissionHashGeneratorTest::testGetCacheableMetadata in Group 8

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

Tests getting the cacheable metadata from the calculated permissions.

@covers ::getCacheableMetadata

File

tests/src/Unit/GroupPermissionHashGeneratorTest.php, line 118

Class

GroupPermissionHashGeneratorTest
Tests the group permission hash generator service.

Namespace

Drupal\Tests\group\Unit

Code

public function testGetCacheableMetadata() {
  $calculated_permissions = $this
    ->prophesize(CalculatedGroupPermissionsInterface::class);
  $calculated_permissions
    ->getCacheContexts()
    ->willReturn([]);
  $calculated_permissions
    ->getCacheTags()
    ->willReturn([
    "config:group.role.foo-bar",
  ]);
  $calculated_permissions
    ->getCacheMaxAge()
    ->willReturn(-1);
  $calculated_permissions = $calculated_permissions
    ->reveal();
  $this->permissionCalculator
    ->calculatePermissions($this->account)
    ->willReturn($calculated_permissions);
  $this
    ->assertEquals(CacheableMetadata::createFromObject($calculated_permissions), $this->hashGenerator
    ->getCacheableMetadata($this->account));
}