You are here

function MatcherDumperTest::testAddAdditionalRoutes in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Routing/MatcherDumperTest.php \Drupal\system\Tests\Routing\MatcherDumperTest::testAddAdditionalRoutes()

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

File

core/modules/system/src/Tests/Routing/MatcherDumperTest.php, line 82
Contains \Drupal\system\Tests\Routing\MatcherDumperTest.

Class

MatcherDumperTest
Confirm that the matcher dumper is functioning properly.

Namespace

Drupal\system\Tests\Routing

Code

function testAddAdditionalRoutes() {
  $connection = Database::getConnection();
  $dumper = new MatcherDumper($connection, $this->state);
  $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.');
  }
}