public function RouteBuilderTest::testRebuildWithStaticModuleRoutes in Drupal 8
Tests that provided routes by a module is put into the dumper/dispatcher.
See also
\Drupal\Core\Routing\RouteBuilder::rebuild()
File
- core/
tests/ Drupal/ Tests/ Core/ Routing/ RouteBuilderTest.php, line 142 - Contains \Drupal\Tests\Core\Routing\RouteBuilderTest.
Class
- RouteBuilderTest
- @coversDefaultClass \Drupal\Core\Routing\RouteBuilder @group Routing
Namespace
Drupal\Tests\Core\RoutingCode
public function testRebuildWithStaticModuleRoutes() {
$this->lock
->expects($this
->once())
->method('acquire')
->with('router_rebuild')
->will($this
->returnValue(TRUE));
$routing_fixtures = new RoutingFixtures();
$routes = $routing_fixtures
->staticSampleRouteCollection();
$this->yamlDiscovery
->expects($this
->once())
->method('findAll')
->will($this
->returnValue([
'test_module' => $routes,
]));
$route_collection = $routing_fixtures
->sampleRouteCollection();
foreach ($route_collection
->all() as $route) {
$route
->setOption('compiler_class', RouteCompiler::class);
}
$route_build_event = new RouteBuildEvent($route_collection);
// Ensure that the alter routes events are fired.
$this->dispatcher
->expects($this
->at(0))
->method('dispatch')
->with(RoutingEvents::DYNAMIC, $route_build_event);
$this->dispatcher
->expects($this
->at(1))
->method('dispatch')
->with(RoutingEvents::ALTER, $route_build_event);
// Ensure that access checks are set.
$this->checkProvider
->expects($this
->once())
->method('setChecks')
->with($route_collection);
// Ensure that the routes are set to the dumper and dumped.
$this->dumper
->expects($this
->at(0))
->method('addRoutes')
->with($route_collection);
$this->dumper
->expects($this
->at(1))
->method('dump')
->with();
$this
->assertTrue($this->routeBuilder
->rebuild());
}