staticSampleRouteCollection example


  public function testGetAllRoutes() {
    $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, $this->logger, 'test_routes');
    $dumper->addRoutes($this->fixtures->SampleRouteCollection());
    $dumper->dump();

    $sample_routes = $this->fixtures->staticSampleRouteCollection();

    $returned_routes = $provider->getAllRoutes();

    $this->assertInstanceOf(\Iterator::class$returned_routes);
    $this->assertSameSize($sample_routes$returned_routes);

    foreach ($returned_routes as $route_name => $route) {
      $this->assertArrayHasKey($route_name$sample_routes);
      $this->assertEquals($route->getPath()$sample_routes[$route_name]['path']);
    }
  }

  

  public function testRebuildWithStaticModuleRoutes() {
    $this->lock->expects($this->once())
      ->method('acquire')
      ->with('router_rebuild')
      ->willReturn(TRUE);

    $routing_fixtures = new RoutingFixtures();
    $routes = $routing_fixtures->staticSampleRouteCollection();

    $this->yamlDiscovery->expects($this->once())
      ->method('findAll')
      ->willReturn(['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);

    
Home | Imprint | This part of the site doesn't use cookies.