diff --git a/src/Shell/RoutesShell.php b/src/Shell/RoutesShell.php index 3972fd528ca..1f901599c23 100644 --- a/src/Shell/RoutesShell.php +++ b/src/Shell/RoutesShell.php @@ -38,7 +38,8 @@ public function main() ['Route name', 'URI template', 'Defaults'] ]; foreach (Router::routes() as $route) { - $output[] = [$route->getName(), $route->template, json_encode($route->defaults)]; + $name = isset($route->options['_name']) ? $route->options['_name'] : $route->getName(); + $output[] = [$name, $route->template, json_encode($route->defaults)]; } $this->helper('table')->output($output); } diff --git a/tests/TestCase/Shell/RoutesShellTest.php b/tests/TestCase/Shell/RoutesShellTest.php index d3aad83dfe3..a4a0688254e 100644 --- a/tests/TestCase/Shell/RoutesShellTest.php +++ b/tests/TestCase/Shell/RoutesShellTest.php @@ -45,6 +45,7 @@ public function setUp() $this->shell = new RoutesShell($this->io); Router::connect('/articles/:action/*', ['controller' => 'Articles']); Router::connect('/bake/:controller/:action', ['plugin' => 'Bake']); + Router::connect('/tests/:action/*', ['controller' => 'Tests'], ['_name' => 'testName']); } /** @@ -75,6 +76,16 @@ public function testMain() 'articles:_action', '/articles/:action/*', '{"controller":"Articles","action":"index","plugin":null}' + ]), + $this->contains([ + 'bake._controller:_action', + '/bake/:controller/:action', + '{"plugin":"Bake","action":"index"}', + ]), + $this->contains([ + 'testName', + '/tests/:action/*', + '{"controller":"Tests","action":"index","plugin":null}' ]) ) );