function MatcherDumperTest::testAddRoutes

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php \Drupal\KernelTests\Core\Routing\MatcherDumperTest::testAddRoutes()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php \Drupal\KernelTests\Core\Routing\MatcherDumperTest::testAddRoutes()
  3. 11.x core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php \Drupal\KernelTests\Core\Routing\MatcherDumperTest::testAddRoutes()

Confirms that we can add routes to the dumper.

File

core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php, line 73

Class

MatcherDumperTest
Confirm that the matcher dumper is functioning properly.

Namespace

Drupal\KernelTests\Core\Routing

Code

public function testAddRoutes() : void {
  $connection = Database::getConnection();
  $dumper = new MatcherDumper($connection, $this->state, $this->logger);
  $route = new Route('test');
  $collection = new RouteCollection();
  $collection->add('test_route', $route);
  $dumper->addRoutes($collection);
  $dumper_routes = $dumper->getRoutes()
    ->all();
  $collection_routes = $collection->all();
  foreach ($dumper_routes as $name => $route) {
    $this->assertEquals($collection_routes[$name]->getPath(), $route->getPath(), 'Routes match');
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.