function DefaultAccessCheckTest::testAccess
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Access/DefaultAccessCheckTest.php \Drupal\Tests\Core\Access\DefaultAccessCheckTest::testAccess()
- 8.9.x core/tests/Drupal/Tests/Core/Access/DefaultAccessCheckTest.php \Drupal\Tests\Core\Access\DefaultAccessCheckTest::testAccess()
- 11.x core/tests/Drupal/Tests/Core/Access/DefaultAccessCheckTest.php \Drupal\Tests\Core\Access\DefaultAccessCheckTest::testAccess()
Tests the access method.
File
-
core/
tests/ Drupal/ Tests/ Core/ Access/ DefaultAccessCheckTest.php, line 46
Class
- DefaultAccessCheckTest
- @coversDefaultClass \Drupal\Core\Access\DefaultAccessCheck @group Access
Namespace
Drupal\Tests\Core\AccessCode
public function testAccess() : void {
$request = new Request([]);
$route = new Route('/test-route', [], [
'_access' => 'NULL',
]);
$this->assertEquals(AccessResult::neutral(), $this->accessChecker
->access($route, $request, $this->account));
$route = new Route('/test-route', [], [
'_access' => 'FALSE',
]);
$this->assertEquals(AccessResult::forbidden(), $this->accessChecker
->access($route, $request, $this->account));
$route = new Route('/test-route', [], [
'_access' => 'TRUE',
]);
$this->assertEquals(AccessResult::allowed(), $this->accessChecker
->access($route, $request, $this->account));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.