function PermissionsHashGeneratorTest::testGenerateRegular

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

Tests the generate method for regular accounts.

@covers ::generate

File

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

Class

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

Namespace

Drupal\Tests\Core\Session

Code

public function testGenerateRegular() : void {
    $permissions = new CalculatedPermissions((new RefinableCalculatedPermissions())->addItem(new CalculatedPermissionsItem([
        'permission foo',
        'permission bar',
    ])));
    $this->processor
        ->processAccessPolicies($this->account1)
        ->willReturn($permissions);
    $this->processor
        ->processAccessPolicies($this->account2)
        ->willReturn($permissions);
    // Check that two accounts with the same permissions generate the same hash.
    $hash_1 = $this->permissionsHash
        ->generate($this->account1);
    $hash_2 = $this->permissionsHash
        ->generate($this->account2);
    $this->assertSame($hash_1, $hash_2, 'Different users with the same permissions generate the same permissions hash.');
}

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