function MatcherDumperTest::testAddAdditionalRoutes

Confirms that we can add routes to the dumper when it already has some.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Routing/MatcherDumperTest.php, line 82
Definition of Drupal\system\Tests\Routing\UrlMatcherDumperTest.

Class

MatcherDumperTest
Basic tests for the UrlMatcherDumper.

Namespace

Drupal\system\Tests\Routing

Code

function testAddAdditionalRoutes() {
  $connection = Database::getConnection();
  $dumper = new MatcherDumper($connection);
  $route = new Route('test');
  $collection = new RouteCollection();
  $collection
    ->add('test_route', $route);
  $dumper
    ->addRoutes($collection);
  $route = new Route('test2');
  $collection2 = new RouteCollection();
  $collection2
    ->add('test_route2', $route);
  $dumper
    ->addRoutes($collection2);

  // Merge the two collections together so we can test them.
  $collection
    ->addCollection(clone $collection2);
  $dumper_routes = $dumper
    ->getRoutes()
    ->all();
  $collection_routes = $collection
    ->all();
  $success = TRUE;
  foreach ($collection_routes as $name => $route) {
    if (empty($dumper_routes[$name])) {
      $success = FALSE;
      $this
        ->fail(t('Not all routes found in the dumper.'));
    }
  }
  if ($success) {
    $this
      ->pass('All routes found in the dumper.');
  }
}