public function AccessTest::testRoleDelegationAccess in Role Delegation 8
Test the access checker for user/%/roles.
@covers ::access
File
- tests/
src/ Kernel/ AccessTest.php, line 50
Class
- AccessTest
- @coversDefaultClass \Drupal\role_delegation\Access\RoleDelegationAccessCheck
Namespace
Drupal\Tests\role_delegation\KernelCode
public function testRoleDelegationAccess() {
// Anonymous users can never access the roles page.
$account = $this
->createUser();
$this
->assertEquals(FALSE, $this->accessChecker
->access($account)
->isAllowed());
// Users with "administer permissions" cannot view the page, they must use
// the normal user edit page or also "have assign all roles".
$account = $this
->createUser([
'administer permissions',
]);
$this
->assertEquals(FALSE, $this->accessChecker
->access($account)
->isAllowed());
// Users with a custom "assign %custom role" permission should be able to
// see the role admin page.
$role = $this
->createRole([]);
$account = $this
->createUser([
sprintf('assign %s role', $role),
]);
$this
->assertEquals(TRUE, $this->accessChecker
->access($account)
->isAllowed());
// Users with 'assign all roles' can view the page.
$account = $this
->createUser([
'assign all roles',
]);
$this
->assertEquals(TRUE, $this->accessChecker
->access($account)
->isAllowed());
}