Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
1c3b92be
Commit
1c3b92be
authored
Nov 11, 2013
by
webchick
Browse files
Issue
#2132795
by tstoeckler: Remove \Drupal\Core\Routing\RouteCompiler::MAX_PARTS.
parent
99fc3faa
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Routing/RouteCompiler.php
View file @
1c3b92be
...
...
@@ -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.
...
...
core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php
View file @
1c3b92be
...
...
@@ -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.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment