function PermissionsHashGeneratorTest::testGeneratePersistentCache

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php \Drupal\Tests\Core\Session\PermissionsHashGeneratorTest::testGeneratePersistentCache()

@covers ::generate

File

core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php, line 171

Class

PermissionsHashGeneratorTest
@coversDefaultClass \Drupal\Core\Session\PermissionsHashGenerator @group Session

Namespace

Drupal\Tests\Core\Session

Code

public function testGeneratePersistentCache() {
    // Set expectations for the mocked cache backend.
    $expected_cid = 'user_permissions_hash:administrator,authenticated';
    $mock_cache = new \stdClass();
    $mock_cache->data = 'test_hash_here';
    $this->staticCache
        ->expects($this->once())
        ->method('get')
        ->with($expected_cid)
        ->willReturn(FALSE);
    $this->staticCache
        ->expects($this->once())
        ->method('set')
        ->with($expected_cid, $this->isType('string'));
    $this->cache
        ->expects($this->once())
        ->method('get')
        ->with($expected_cid)
        ->willReturn($mock_cache);
    $this->cache
        ->expects($this->never())
        ->method('set');
    $this->permissionsHash
        ->generate($this->account2);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.