Esempio n. 1
0
 /**
  * Tests getRoutesPaged().
  */
 public function testGetRoutesPaged()
 {
     $connection = Database::getConnection();
     $provider = new RouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
     $this->fixtures->createTables($connection);
     $dumper = new MatcherDumper($connection, $this->state, 'test_routes');
     $dumper->addRoutes($this->fixtures->sampleRouteCollection());
     $dumper->dump();
     $fixture_routes = $this->fixtures->staticSampleRouteCollection();
     // Query all the routes.
     $routes = $provider->getRoutesPaged(0);
     $this->assertEqual(array_keys($routes), array_keys($fixture_routes));
     // Query non routes.
     $routes = $provider->getRoutesPaged(0, 0);
     $this->assertEqual(array_keys($routes), []);
     // Query a limited sets of routes.
     $routes = $provider->getRoutesPaged(1, 2);
     $this->assertEqual(array_keys($routes), array_slice(array_keys($fixture_routes), 1, 2));
 }
 /**
  * Tests that provided routes by a module is put into the dumper/dispatcher.
  *
  * @see \Drupal\Core\Routing\RouteBuilder::rebuild()
  */
 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 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());
 }