function PermissionsHashGeneratorTest::testGenerateAdmin

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

Tests the generate method for admin users.

@covers ::generate

File

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

Class

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

Namespace

Drupal\Tests\Core\Session

Code

public function testGenerateAdmin() : void {
    $permissions = new CalculatedPermissions((new RefinableCalculatedPermissions())->addItem(new CalculatedPermissionsItem([], TRUE)));
    $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 admins generate the same permissions hash.');
    // Check that the generated hash is simply 'is-admin'.
    $this->assertSame('is-admin', $hash_1, 'Admins generate the string "is-admin" as their permissions hash.');
}

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