Skip to content

Commit

Permalink
Fix parsing bool values out of route shell.
Browse files Browse the repository at this point in the history
`cake routes generate` should allow the usage of boolean parameters.
This is necessary to test `_ssl` and a few other flag options.
  • Loading branch information
markstory committed Mar 2, 2017
1 parent f392eb4 commit 2323b70
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Shell/RoutesShell.php
Expand Up @@ -137,6 +137,9 @@ protected function _splitArgs($args)
foreach ($args as $arg) {
if (strpos($arg, ':') !== false) {
list($key, $value) = explode(':', $arg);
if (in_array($value, ['true', 'false'])) {
$value = $value === 'true' ? true : false;
}
$out[$key] = $value;
} else {
$out[] = $arg;
Expand Down
17 changes: 17 additions & 0 deletions tests/TestCase/Shell/RoutesShellTest.php
Expand Up @@ -173,6 +173,23 @@ public function testGenerate()
$this->shell->generate();
}

/**
* Test generating URLs with bool params
*
* @return void
*/
public function testGenerateBoolParams()
{
$this->io->expects($this->never())
->method('err');
$this->io->expects($this->at(0))
->method('out')
->with($this->stringContains('> https://example.com/articles/index'));

$this->shell->args = ['_ssl:true', '_host:example.com', 'controller:Articles', 'action:index'];
$this->shell->generate();
}

/**
* Test generating URLs
*
Expand Down

0 comments on commit 2323b70

Please sign in to comment.