public function RoutePreloaderTest::testOnAlterRoutesWithAdminPathNoAdminRoute in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php \Drupal\Tests\Core\Routing\RoutePreloaderTest::testOnAlterRoutesWithAdminPathNoAdminRoute()
Tests onAlterRoutes with "admin" appearing in the path.
File
- core/
tests/ Drupal/ Tests/ Core/ Routing/ RoutePreloaderTest.php, line 80
Class
- RoutePreloaderTest
- @coversDefaultClass \Drupal\Core\Routing\RoutePreloader @group Routing
Namespace
Drupal\Tests\Core\RoutingCode
public function testOnAlterRoutesWithAdminPathNoAdminRoute() {
$event = $this
->getMockBuilder('Drupal\\Core\\Routing\\RouteBuildEvent')
->disableOriginalConstructor()
->getMock();
$route_collection = new RouteCollection();
$route_collection
->add('test', new Route('/foo/admin/foo', [
'_controller' => 'Drupal\\ExampleController',
]));
$route_collection
->add('test2', new Route('/bar/admin/bar', [
'_controller' => 'Drupal\\ExampleController',
]));
$route_collection
->add('test3', new Route('/administrator/a', [
'_controller' => 'Drupal\\ExampleController',
]));
$route_collection
->add('test4', new Route('/admin', [
'_controller' => 'Drupal\\ExampleController',
]));
$event
->expects($this
->once())
->method('getRouteCollection')
->will($this
->returnValue($route_collection));
$this->state
->expects($this
->once())
->method('set')
->with('routing.non_admin_routes', [
'test',
'test2',
'test3',
]);
$this->preloader
->onAlterRoutes($event);
$this->preloader
->onFinishedRoutes(new Event());
}