function RouteProviderTest::testOutlinePathMatchDefaultsCollision3
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::testOutlinePathMatchDefaultsCollision3()
- 10 core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::testOutlinePathMatchDefaultsCollision3()
- 11.x core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::testOutlinePathMatchDefaultsCollision3()
Confirms that we can find multiple routes that match the request equally.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Routing/ RouteProviderTest.php, line 442
Class
- RouteProviderTest
- Confirm that the default route provider is working correctly.
Namespace
Drupal\KernelTests\Core\RoutingCode
public function testOutlinePathMatchDefaultsCollision3() {
$connection = Database::getConnection();
$provider = new RouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
$this->fixtures
->createTables($connection);
$collection = new RouteCollection();
$collection->add('poink', new Route('/some/{value}/path'));
// Add a second route matching the same path pattern.
$collection->add('poink2', new Route('/some/{object}/path'));
$collection->add('narf', new Route('/some/here/path'));
$collection->add('eep', new Route('/something/completely/different'));
$dumper = new MatcherDumper($connection, $this->state, 'test_routes');
$dumper->addRoutes($collection);
$dumper->dump();
$path = '/some/over-there/path';
$request = Request::create($path, 'GET');
try {
$routes = $provider->getRouteCollectionForRequest($request);
$routes_array = $routes->all();
$this->assertCount(2, $routes, 'The correct number of routes was found.');
$this->assertEqual([
'poink',
'poink2',
], array_keys($routes_array), 'Ensure the fitness and name were taken into account in the sort.');
$this->assertNotNull($routes->get('poink'), 'The first matching route was found.');
$this->assertNotNull($routes->get('poink2'), 'The second matching route was found.');
$this->assertNull($routes->get('eep'), 'Non-matching route was not found.');
} catch (ResourceNotFoundException $e) {
$this->fail('No matching route found with default argument value.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.