Skip to content

Commit

Permalink
Merge pull request #12097 from cakephp/ad-sort-routes-cli
Browse files Browse the repository at this point in the history
Sort route defaults consistently in the routes cli
  • Loading branch information
dereuromark committed May 18, 2018
2 parents ea70497 + ce1e801 commit a88b2ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/Shell/RoutesShell.php
Expand Up @@ -38,6 +38,7 @@ public function main()
];
foreach (Router::routes() as $route) {
$name = isset($route->options['_name']) ? $route->options['_name'] : $route->getName();
ksort($route->defaults);
$output[] = [$name, $route->template, json_encode($route->defaults)];
}
$this->helper('table')->output($output);
Expand All @@ -64,6 +65,7 @@ public function check($url)
}

unset($route['_matchedRoute']);
ksort($route);

$output = [
['Route name', 'URI template', 'Defaults'],
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Shell/RoutesShellTest.php
Expand Up @@ -65,17 +65,17 @@ public function testMain()
$this->assertOutputContainsRow([
'articles:_action',
'/articles/:action/*',
'{"controller":"Articles","action":"index","plugin":null}'
'{"action":"index","controller":"Articles","plugin":null}'
]);
$this->assertOutputContainsRow([
'bake._controller:_action',
'/bake/:controller/:action',
'{"plugin":"Bake","action":"index"}'
'{"action":"index","plugin":"Bake"}'
]);
$this->assertOutputContainsRow([
'testName',
'/tests/:action/*',
'{"controller":"Tests","action":"index","plugin":null}'
'{"action":"index","controller":"Tests","plugin":null}'
]);
}

Expand All @@ -96,7 +96,7 @@ public function testCheck()
$this->assertOutputContainsRow([
'articles:_action',
'/articles/check',
'{"action":"check","pass":[],"controller":"Articles","plugin":null}'
'{"action":"check","controller":"Articles","pass":[],"plugin":null}'
]);
}

Expand All @@ -117,7 +117,7 @@ public function testCheckWithNamedRoute()
$this->assertOutputContainsRow([
'testName',
'/tests/index',
'{"action":"index","pass":[],"controller":"Tests","plugin":null,"_name":"testName"}'
'{"_name":"testName","action":"index","controller":"Tests","pass":[],"plugin":null}'
]);
}

Expand Down

0 comments on commit a88b2ab

Please sign in to comment.