You are here

public function DefaultAccessCheckTest::testAccess in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 49
Contains \Drupal\Tests\Core\Access\DefaultAccessCheckTest.

Class

DefaultAccessCheckTest
@coversDefaultClass \Drupal\Core\Access\DefaultAccessCheck @group Access

Namespace

Drupal\Tests\Core\Access

Code

public function testAccess() {
  $request = new Request(array());
  $route = new Route('/test-route', array(), array(
    '_access' => 'NULL',
  ));
  $this
    ->assertEquals(AccessResult::neutral(), $this->accessChecker
    ->access($route, $request, $this->account));
  $route = new Route('/test-route', array(), array(
    '_access' => 'FALSE',
  ));
  $this
    ->assertEquals(AccessResult::forbidden(), $this->accessChecker
    ->access($route, $request, $this->account));
  $route = new Route('/test-route', array(), array(
    '_access' => 'TRUE',
  ));
  $this
    ->assertEquals(AccessResult::allowed(), $this->accessChecker
    ->access($route, $request, $this->account));
}