Skip to content

Commit 2323b70

Browse files
committed
Fix parsing bool values out of route shell.
`cake routes generate` should allow the usage of boolean parameters. This is necessary to test `_ssl` and a few other flag options.
1 parent f392eb4 commit 2323b70

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Shell/RoutesShell.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ protected function _splitArgs($args)
137137
foreach ($args as $arg) {
138138
if (strpos($arg, ':') !== false) {
139139
list($key, $value) = explode(':', $arg);
140+
if (in_array($value, ['true', 'false'])) {
141+
$value = $value === 'true' ? true : false;
142+
}
140143
$out[$key] = $value;
141144
} else {
142145
$out[] = $arg;

tests/TestCase/Shell/RoutesShellTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,23 @@ public function testGenerate()
173173
$this->shell->generate();
174174
}
175175

176+
/**
177+
* Test generating URLs with bool params
178+
*
179+
* @return void
180+
*/
181+
public function testGenerateBoolParams()
182+
{
183+
$this->io->expects($this->never())
184+
->method('err');
185+
$this->io->expects($this->at(0))
186+
->method('out')
187+
->with($this->stringContains('> https://example.com/articles/index'));
188+
189+
$this->shell->args = ['_ssl:true', '_host:example.com', 'controller:Articles', 'action:index'];
190+
$this->shell->generate();
191+
}
192+
176193
/**
177194
* Test generating URLs
178195
*

0 commit comments

Comments
 (0)