function PermissionsHashGeneratorTest::testGenerateStaticCache

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

@covers ::generate

File

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

Class

PermissionsHashGeneratorTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Session%21PermissionsHashGenerator.php/class/PermissionsHashGenerator/9" title="Generates and caches the permissions hash for a user." class="local">\Drupal\Core\Session\PermissionsHashGenerator</a> @group Session

Namespace

Drupal\Tests\Core\Session

Code

public function testGenerateStaticCache() {
    // 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($mock_cache);
    $this->staticCache
        ->expects($this->never())
        ->method('set');
    $this->cache
        ->expects($this->never())
        ->method('get');
    $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.