You are here

public function RouteBuilderTest::testRebuildWithStaticModuleRoutes in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php \Drupal\Tests\Core\Routing\RouteBuilderTest::testRebuildWithStaticModuleRoutes()

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 141
Contains \Drupal\Tests\Core\Routing\RouteBuilderTest.

Class

RouteBuilderTest
@coversDefaultClass \Drupal\Core\Routing\RouteBuilder @group Routing

Namespace

Drupal\Tests\Core\Routing

Code

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(array(
    'test_module' => $routes,
  )));
  $route_collection = $routing_fixtures
    ->sampleRouteCollection();
  $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());
}