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
7724c193
Commit
7724c193
authored
Apr 09, 2013
by
webchick
Browse files
Issue
#1959122
by Crell, tim.plunkett, chx: Fixed Optional params are not possible in routes.
parent
13b3e276
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Routing/RouteProvider.php
View file @
7724c193
...
...
@@ -206,7 +206,7 @@ public function getCandidateOutlines(array $parts) {
// The highest possible mask is a 1 bit for every part of the path. We will
// check every value down from there to generate a possible outline.
$masks
=
range
(
$end
,
pow
(
$number_parts
-
1
,
2
)
);
$masks
=
range
(
$end
,
0
);
// Only examine patterns that actually exist as router items (the masks).
foreach
(
$masks
as
$i
)
{
...
...
core/modules/system/lib/Drupal/system/Tests/Routing/RouteProviderTest.php
View file @
7724c193
...
...
@@ -66,11 +66,15 @@ public function testCandidateOutlines() {
$candidates
=
array_flip
(
$candidates
);
$this
->
assertTrue
(
count
(
$candidates
)
==
4
,
'Correct number of candidates found'
);
$this
->
assertTrue
(
count
(
$candidates
)
==
8
,
'Correct number of candidates found'
);
$this
->
assertTrue
(
array_key_exists
(
'/node/5/edit'
,
$candidates
),
'First candidate found.'
);
$this
->
assertTrue
(
array_key_exists
(
'/node/5/%'
,
$candidates
),
'Second candidate found.'
);
$this
->
assertTrue
(
array_key_exists
(
'/node/%/edit'
,
$candidates
),
'Third candidate found.'
);
$this
->
assertTrue
(
array_key_exists
(
'/node/%/%'
,
$candidates
),
'Fourth candidate found.'
);
$this
->
assertTrue
(
array_key_exists
(
'/node/5'
,
$candidates
),
'Fifth candidate found.'
);
$this
->
assertTrue
(
array_key_exists
(
'/node/%'
,
$candidates
),
'Sixth candidate found.'
);
$this
->
assertTrue
(
array_key_exists
(
'/node'
,
$candidates
),
'Seventh candidate found.'
);
$this
->
assertTrue
(
array_key_exists
(
'/'
,
$candidates
),
'Eighth candidate found.'
);
}
/**
...
...
@@ -246,6 +250,7 @@ function testOutlinePathMatchDefaultsCollision2() {
'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
);
...
...
@@ -258,13 +263,10 @@ function testOutlinePathMatchDefaultsCollision2() {
try
{
$routes
=
$provider
->
getRouteCollectionForRequest
(
$request
);
// All of the matching paths have the correct pattern.
foreach
(
$routes
as
$route
)
{
$this
->
assertEqual
(
$route
->
compile
()
->
getPatternOutline
(),
'/some/path/here'
,
'Found path has correct pattern'
);
}
$this
->
assertEqual
(
count
(
$routes
),
1
,
'The correct number of routes was found.'
);
$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.'
);
...
...
core/modules/system/lib/Drupal/system/Tests/Routing/RouterTest.php
View file @
7724c193
...
...
@@ -79,6 +79,7 @@ public function testControllerPlaceholders() {
*/
public
function
testControllerPlaceholdersDefaultValues
()
{
$this
->
drupalGet
(
'router_test/test4'
);
$this
->
assertResponse
(
200
);
$this
->
assertRaw
(
'narf'
,
'The correct string was returned because the route was successful.'
);
// Confirm that the page wrapping is being added, so we're not getting a
...
...
@@ -90,6 +91,23 @@ public function testControllerPlaceholdersDefaultValues() {
$this
->
assertNoPattern
(
'#</body>.*</body>#s'
,
'There was no double-page effect from a misrendered subrequest.'
);
}
/**
* Confirms that default placeholders in paths work correctly.
*/
public
function
testControllerPlaceholdersDefaultValuesProvided
()
{
$this
->
drupalGet
(
'router_test/test4/barf'
);
$this
->
assertResponse
(
200
);
$this
->
assertRaw
(
'barf'
,
'The correct string was returned because the route was successful.'
);
// Confirm that the page wrapping is being added, so we're not getting a
// raw body returned.
$this
->
assertRaw
(
'</html>'
,
'Page markup was found.'
);
// In some instances, the subrequest handling may get confused and render
// a page inception style. This test verifies that is not happening.
$this
->
assertNoPattern
(
'#</body>.*</body>#s'
,
'There was no double-page effect from a misrendered subrequest.'
);
}
/**
* Checks that dynamically defined and altered routes work correctly.
*
...
...
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