function PermissionsHashGeneratorTest::testGenerateCache
Same name in other branches
- 11.x core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php \Drupal\Tests\Core\Session\PermissionsHashGeneratorTest::testGenerateCache()
Tests the generate method's caching.
@covers ::generate
File
-
core/
tests/ Drupal/ Tests/ Core/ Session/ PermissionsHashGeneratorTest.php, line 158
Class
- PermissionsHashGeneratorTest
- @coversDefaultClass \Drupal\Core\Session\PermissionsHashGenerator @group Session
Namespace
Drupal\Tests\Core\SessionCode
public function testGenerateCache() : void {
$permissions = new CalculatedPermissions(new RefinableCalculatedPermissions());
$this->processor
->processAccessPolicies($this->account1)
->willReturn($permissions);
$this->processor
->processAccessPolicies($this->account2)
->willReturn($permissions);
// Test that set is called with the right cache ID.
$this->staticCache
->set('permissions_hash_1', 'no-access-policies', Cache::PERMANENT, [])
->shouldBeCalledOnce();
$this->staticCache
->set('permissions_hash_2', 'no-access-policies', Cache::PERMANENT, [])
->shouldBeCalledOnce();
$this->permissionsHash
->generate($this->account1);
$this->permissionsHash
->generate($this->account2);
// Verify that ::set() isn't called more when ::get() returns something.
$cache_return = new \stdClass();
$cache_return->data = 'no-access-policies';
$this->staticCache
->get('permissions_hash_1')
->willReturn($cache_return);
$this->staticCache
->get('permissions_hash_2')
->willReturn($cache_return);
$this->permissionsHash
->generate($this->account1);
$this->permissionsHash
->generate($this->account2);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.