public function DefaultAccessCheckTest::testAccess in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Access/DefaultAccessCheckTest.php \Drupal\Tests\Core\Access\DefaultAccessCheckTest::testAccess()
Test the access method.
File
- core/
tests/ Drupal/ Tests/ Core/ Access/ DefaultAccessCheckTest.php, line 44
Class
- DefaultAccessCheckTest
- @coversDefaultClass \Drupal\Core\Access\DefaultAccessCheck @group Access
Namespace
Drupal\Tests\Core\AccessCode
public function testAccess() {
$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));
}