Skip to content

Commit

Permalink
Names starting with spaces are invalid.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 5, 2017
1 parent 1a0c868 commit ccee4f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Console/Command.php
Expand Up @@ -77,7 +77,7 @@ public function __construct()
*/
public function setName($name)
{
if (strpos($name, ' ') === false) {
if (strpos($name, ' ') < 1) {
throw new InvalidArgumentException(
"The name '{$name}' is missing a space. Names should look like `cake routes`"
);
Expand Down
12 changes: 12 additions & 0 deletions tests/TestCase/Console/CommandTest.php
Expand Up @@ -77,6 +77,18 @@ public function testSetNameInvalid()
$command->setName('routes_show');
}

/**
* Test invalid name
*
* @expectedException InvalidArgumentException
* @return void
*/
public function testSetNameInvalidLeadingSpace()
{
$command = new Command();
$command->setName(' routes_show');
}

/**
* Test option parser fetching
*
Expand Down

0 comments on commit ccee4f5

Please sign in to comment.