function AccessManagerTest::testCheckNamedRoute
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::testCheckNamedRoute()
- 10 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 331
Class
- AccessManagerTest
- @coversDefaultClass \Drupal\Core\Access\AccessManager @group Access
Namespace
Drupal\Tests\Core\AccessCode
public function testCheckNamedRoute() {
$this->setupAccessChecker();
$this->checkProvider
->setChecks($this->routeCollection);
$this->setupAccessArgumentsResolverFactory();
$this->paramConverter
->expects($this->at(0))
->method('convert')
->with([
RouteObjectInterface::ROUTE_NAME => 'test_route_2',
RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection
->get('test_route_2'),
])
->will($this->returnValue([]));
$this->paramConverter
->expects($this->at(1))
->method('convert')
->with([
RouteObjectInterface::ROUTE_NAME => 'test_route_2',
RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection
->get('test_route_2'),
])
->will($this->returnValue([]));
$this->paramConverter
->expects($this->at(2))
->method('convert')
->with([
'value' => 'example',
RouteObjectInterface::ROUTE_NAME => 'test_route_4',
RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection
->get('test_route_4'),
])
->will($this->returnValue([
'value' => 'example',
]));
$this->paramConverter
->expects($this->at(3))
->method('convert')
->with([
'value' => 'example',
RouteObjectInterface::ROUTE_NAME => 'test_route_4',
RouteObjectInterface::ROUTE_OBJECT => $this->routeCollection
->get('test_route_4'),
])
->will($this->returnValue([
'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.