function PathMatcherTest::testOutlinePathMatchDefaultsCollision

Confirms that we can find routes whose pattern would match the request.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Routing/PathMatcherTest.php, line 199
Definition of Drupal\system\Tests\Routing\PartialMatcherTest.

Class

PathMatcherTest
Basic tests for the UrlMatcherDumper.

Namespace

Drupal\system\Tests\Routing

Code

function testOutlinePathMatchDefaultsCollision() {
  $connection = Database::getConnection();
  $matcher = new PathMatcher($connection, 'test_routes');
  $this->fixtures
    ->createTables($connection);
  $collection = new RouteCollection();
  $collection
    ->add('poink', new Route('/some/path/{value}', array(
    'value' => 'poink',
  )));
  $collection
    ->add('narf', new Route('/some/path/here'));
  $dumper = new MatcherDumper($connection, 'test_routes');
  $dumper
    ->addRoutes($collection);
  $dumper
    ->dump();
  $path = '/some/path';
  $request = Request::create($path, 'GET');
  try {
    $routes = $matcher
      ->matchRequestPartial($request);

    // All of the matching paths have the correct pattern.
    foreach ($routes as $route) {
      $compiled = $route
        ->compile();
      $this
        ->assertEqual($route
        ->compile()
        ->getPatternOutline(), '/some/path', 'Found path has correct pattern');
    }
    $this
      ->assertEqual(count($routes
      ->all()), 1, 'The correct number of routes was found.');
    $this
      ->assertNotNull($routes
      ->get('poink'), 'The first matching route was found.');
  } catch (ResourceNotFoundException $e) {
    $this
      ->fail('No matching route found with default argument value.');
  }
}