function AccessManagerTest::testCheckNamedRouteWithNonExistingRoute

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::testCheckNamedRouteWithNonExistingRoute()
  2. 8.9.x core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::testCheckNamedRouteWithNonExistingRoute()
  3. 11.x 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 447

Class

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

Namespace

Drupal\Tests\Core\Access

Code

public function testCheckNamedRouteWithNonExistingRoute() : void {
    $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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.