Skip to content

Commit

Permalink
lowercase route names.
Browse files Browse the repository at this point in the history
When creating names for reverse routing, always lowercase the names, as
Route::name() will also lowercase the names. With routing keys no longer
being underscored() casing starts to matter more for generated names.

Refs #3752
  • Loading branch information
markstory committed Jun 20, 2014
1 parent d493e91 commit ff1ebb9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Routing/RouteCollection.php
Expand Up @@ -142,7 +142,7 @@ protected function _getNames($url) {
];
}
foreach ($fallbacks as $i => $template) {
$fallbacks[$i] = sprintf($template, $plugin, $url['controller'], $url['action']);
$fallbacks[$i] = strtolower(sprintf($template, $plugin, $url['controller'], $url['action']));
}
if ($name) {
array_unshift($fallbacks, $name);
Expand Down
13 changes: 13 additions & 0 deletions tests/TestCase/Routing/RouterTest.php
Expand Up @@ -701,6 +701,19 @@ public function testUrlGenerationBasic() {
$this->assertEquals($expected, $result);
}

/**
* Test that generated names for routes are case-insensitive.
*
* @return void
*/
public function testRouteNameCasing() {
Router::connect('/articles/:id', ['controller' => 'Articles', 'action' => 'view']);
Router::connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);
$result = Router::url(['controller' => 'Articles', 'action' => 'view', 'id' => 10]);
$expected = '/articles/10';
$this->assertEquals($expected, $result);
}

/**
* Test generation of routes with query string parameters.
*
Expand Down

0 comments on commit ff1ebb9

Please sign in to comment.