function AccessManagerTest::testCheckNamedRoute
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::testCheckNamedRoute()
- 8.9.x core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::testCheckNamedRoute()
- 11.x core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::testCheckNamedRoute()
Tests the checkNamedRoute method.
See also
\Drupal\Core\Access\AccessManager::checkNamedRoute()
File
-
core/
tests/ Drupal/ Tests/ Core/ Access/ AccessManagerTest.php, line 329
Class
- AccessManagerTest
- @coversDefaultClass \Drupal\Core\Access\AccessManager @group Access
Namespace
Drupal\Tests\Core\AccessCode
public function testCheckNamedRoute() : void {
$this->setupAccessChecker();
$this->checkProvider
->setChecks($this->routeCollection);
$this->setupAccessArgumentsResolverFactory();
$this->paramConverter
->expects($this->exactly(4))
->method('convert')
->willReturnMap([
[
[
RouteObjectInterface::ROUTE_NAME => 'test_route_2',
RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection
->get('test_route_2'),
],
[],
],
[
[
'value' => 'example',
RouteObjectInterface::ROUTE_NAME => 'test_route_4',
RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection
->get('test_route_4'),
],
[
'value' => 'example',
],
],
]);
// Tests the access with routes with parameters without given request.
$this->assertEquals(TRUE, $this->accessManager
->checkNamedRoute('test_route_2', [], $this->account));
$this->assertEquals(AccessResult::allowed(), $this->accessManager
->checkNamedRoute('test_route_2', [], $this->account, TRUE));
$this->assertEquals(TRUE, $this->accessManager
->checkNamedRoute('test_route_4', [
'value' => 'example',
], $this->account));
$this->assertEquals(AccessResult::allowed(), $this->accessManager
->checkNamedRoute('test_route_4', [
'value' => 'example',
], $this->account, TRUE));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.