function RouteProviderTest::testOutlinePathMatchDefaultsCollision2

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

File

drupal/core/modules/system/lib/Drupal/system/Tests/Routing/RouteProviderTest.php, line 240
Contains Drupal\system\Tests\Routing\RouteProviderTest.

Class

RouteProviderTest
Basic tests for the RouteProvider.

Namespace

Drupal\system\Tests\Routing

Code

function testOutlinePathMatchDefaultsCollision2() {
  $connection = Database::getConnection();
  $provider = new RouteProvider($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'));
  $collection
    ->add('eep', new Route('/something/completely/different'));
  $dumper = new MatcherDumper($connection, 'test_routes');
  $dumper
    ->addRoutes($collection);
  $dumper
    ->dump();
  $path = '/some/path/here';
  $request = Request::create($path, 'GET');
  try {
    $routes = $provider
      ->getRouteCollectionForRequest($request);
    $this
      ->assertEqual(count($routes), 2, 'The correct number of routes was found.');
    $this
      ->assertNotNull($routes
      ->get('narf'), 'The first matching route was found.');
    $this
      ->assertNotNull($routes
      ->get('poink'), 'The second matching route was found.');
    $this
      ->assertNull($routes
      ->get('eep'), 'Noin-matching route was not found.');
  } catch (ResourceNotFoundException $e) {
    $this
      ->fail('No matching route found with default argument value.');
  }
}