public function AdministrativeRoleCheckTest::testAccess in Lightning Core 8.4
Same name and namespace in other branches
- 8.5 tests/src/Kernel/Access/AdministrativeRoleCheckTest.php \Drupal\Tests\lightning_core\Kernel\Access\AdministrativeRoleCheckTest::testAccess()
- 8 tests/src/Kernel/Access/AdministrativeRoleCheckTest.php \Drupal\Tests\lightning_core\Kernel\Access\AdministrativeRoleCheckTest::testAccess()
- 8.2 tests/src/Kernel/Access/AdministrativeRoleCheckTest.php \Drupal\Tests\lightning_core\Kernel\Access\AdministrativeRoleCheckTest::testAccess()
- 8.3 tests/src/Kernel/Access/AdministrativeRoleCheckTest.php \Drupal\Tests\lightning_core\Kernel\Access\AdministrativeRoleCheckTest::testAccess()
@covers ::access
File
- tests/
src/ Kernel/ Access/ AdministrativeRoleCheckTest.php, line 27
Class
- AdministrativeRoleCheckTest
- @coversDefaultClass \Drupal\lightning_core\Access\AdministrativeRoleCheck
Namespace
Drupal\Tests\lightning_core\Kernel\AccessCode
public function testAccess() {
$admin_role = $this
->randomMachineName();
Role::create([
'id' => $admin_role,
'label' => $admin_role,
'is_admin' => TRUE,
])
->save();
$route = new Route('/foo');
$route_match = new RouteMatch('foo', $route);
$account = User::create();
$account
->addRole($admin_role);
$access_check = new AdministrativeRoleCheck($this->container
->get('entity_type.manager'));
$this
->assertTrue($access_check
->access($route, $route_match, $account)
->isAllowed());
$account
->removeRole($admin_role);
$this
->assertTrue($access_check
->access($route, $route_match, $account)
->isForbidden());
}