Commit 1c3b92be authored by webchick's avatar webchick

Issue #2132795 by tstoeckler: Remove \Drupal\Core\Routing\RouteCompiler::MAX_PARTS.

parent 99fc3faa
......@@ -16,11 +16,6 @@
*/
class RouteCompiler extends SymfonyRouteCompiler implements RouteCompilerInterface {
/**
* The maximum number of path elements for a route pattern;
*/
const MAX_PARTS = 9;
/**
* Utility constant to use for regular expressions against the path.
*/
......@@ -93,7 +88,7 @@ public static function getPatternOutline($path) {
* The fitness of the path, as an integer.
*/
public static function getFit($path) {
$parts = explode('/', trim($path, '/'), static::MAX_PARTS);
$parts = explode('/', trim($path, '/'));
$number_parts = count($parts);
// We store the highest index of parts here to save some work in the fit
// calculation loop.
......
......@@ -7,6 +7,7 @@
namespace Drupal\Tests\Core\Routing;
use Drupal\Core\Routing\RouteCompiler;
use Symfony\Component\Routing\Route;
use Drupal\Tests\UnitTestCase;
......@@ -18,6 +19,9 @@
*/
class RouteCompilerTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Routes',
......@@ -26,6 +30,42 @@ public static function getInfo() {
);
}
/**
* Tests RouteCompiler::getFit().
*
* @param string $path
* A path whose fit will be calculated in the test.
* @param int $expected
* The expected fit returned by RouteCompiler::getFit()
*
* @dataProvider providerTestGetFit
*/
public function testGetFit($path, $expected) {
$route_compiler = new RouteCompiler();
$result = $route_compiler->getFit($path);
$this->assertSame($expected, $result);
}
/**
* Provides data for RouteCompilerTest::testGetFit()
*
* @return array
* An array of arrays, where each inner array has the path whose fit is to
* be calculated as the first value and the expected fit as the second
* value.
*/
public function providerTestGetFit() {
return array(
array('test', 1),
array('/testwithleadingslash', 1),
array('testwithtrailingslash/', 1),
array('/testwithslashes/', 1),
array('test/with/multiple/parts', 15),
array('test/with/{some}/slugs', 13),
array('test/very/long/path/that/drupal/7/could/not/have/handled', 2047),
);
}
/**
* Confirms that a route compiles properly with the necessary data.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment