Browse Source

Names starting with spaces are invalid.

Mark Story 8 years ago
parent
commit
ccee4f539f
2 changed files with 13 additions and 1 deletions
  1. 1 1
      src/Console/Command.php
  2. 12 0
      tests/TestCase/Console/CommandTest.php

+ 1 - 1
src/Console/Command.php

@@ -77,7 +77,7 @@ class Command
      */
     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`"
             );

+ 12 - 0
tests/TestCase/Console/CommandTest.php

@@ -78,6 +78,18 @@ class CommandTest extends TestCase
     }
 
     /**
+     * Test invalid name
+     *
+     * @expectedException InvalidArgumentException
+     * @return void
+     */
+    public function testSetNameInvalidLeadingSpace()
+    {
+        $command = new Command();
+        $command->setName(' routes_show');
+    }
+
+    /**
      * Test option parser fetching
      *
      * @return void