Skip to content

Commit ccee4f5

Browse files
committed
Names starting with spaces are invalid.
1 parent 1a0c868 commit ccee4f5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Console/Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function __construct()
7777
*/
7878
public function setName($name)
7979
{
80-
if (strpos($name, ' ') === false) {
80+
if (strpos($name, ' ') < 1) {
8181
throw new InvalidArgumentException(
8282
"The name '{$name}' is missing a space. Names should look like `cake routes`"
8383
);

tests/TestCase/Console/CommandTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ public function testSetNameInvalid()
7777
$command->setName('routes_show');
7878
}
7979

80+
/**
81+
* Test invalid name
82+
*
83+
* @expectedException InvalidArgumentException
84+
* @return void
85+
*/
86+
public function testSetNameInvalidLeadingSpace()
87+
{
88+
$command = new Command();
89+
$command->setName(' routes_show');
90+
}
91+
8092
/**
8193
* Test option parser fetching
8294
*

0 commit comments

Comments
 (0)