You are here

public function AccessManagerTest::testCheckNamedRouteWithNonExistingRoute in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::testCheckNamedRouteWithNonExistingRoute()

Tests checkNamedRoute given an invalid/non existing route name.

File

core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php, line 460
Contains \Drupal\Tests\Core\Access\AccessManagerTest.

Class

AccessManagerTest
@coversDefaultClass \Drupal\Core\Access\AccessManager @group Access

Namespace

Drupal\Tests\Core\Access

Code

public function testCheckNamedRouteWithNonExistingRoute() {
  $this->routeProvider
    ->expects($this
    ->any())
    ->method('getRouteByName')
    ->will($this
    ->throwException(new RouteNotFoundException()));
  $this
    ->setupAccessChecker();
  $this
    ->assertEquals(FALSE, $this->accessManager
    ->checkNamedRoute('test_route_1', [], $this->account), 'A non existing route lead to access.');
  $this
    ->assertEquals(AccessResult::forbidden()
    ->addCacheTags([
    'config:core.extension',
  ]), $this->accessManager
    ->checkNamedRoute('test_route_1', [], $this->account, TRUE), 'A non existing route lead to access.');
}