public function GroupPermissionsCacheContextTest::testGetCacheableMetadata in Group 8
Same name and namespace in other branches
- 2.0.x tests/src/Unit/GroupPermissionsCacheContextTest.php \Drupal\Tests\group\Unit\GroupPermissionsCacheContextTest::testGetCacheableMetadata()
Tests getting the cacheable metadata from the hash generator.
@covers ::getCacheableMetadata
File
- tests/
src/ Unit/ GroupPermissionsCacheContextTest.php, line 61
Class
- GroupPermissionsCacheContextTest
- Tests the user.group_permissions cache context.
Namespace
Drupal\Tests\group\UnitCode
public function testGetCacheableMetadata() {
$cacheable_metadata = new CacheableMetadata();
$cacheable_metadata
->addCacheTags([
"config:group.role.foo-bar",
]);
$this->permissionsHashGenerator
->getCacheableMetadata($this->currentUser
->reveal())
->willReturn($cacheable_metadata);
$cache_context = new GroupPermissionsCacheContext($this->currentUser
->reveal(), $this->permissionsHashGenerator
->reveal());
$this
->assertEquals($cacheable_metadata, $cache_context
->getCacheableMetadata(), 'The cache context gets its cacheable metadata directly from the hash generator.');
}