Browse Source

Merge pull request #10886 from cakephp/remove-root-validation

Remove root command comparisons.
José Lorenzo Rodríguez 8 years ago
parent
commit
2d000451b8
2 changed files with 3 additions and 24 deletions
  1. 2 5
      src/Console/CommandRunner.php
  2. 1 19
      tests/TestCase/Console/CommandRunnerTest.php

+ 2 - 5
src/Console/CommandRunner.php

@@ -127,11 +127,8 @@ class CommandRunner
         }
         $this->dispatchEvent('Console.buildCommands', ['commands' => $commands]);
 
-        if (empty($argv) || $argv[0] !== $this->root) {
-            $command = empty($argv) ? '' : " `{$argv[0]}`";
-            throw new RuntimeException(
-                "Unknown root command{$command}. Was expecting `{$this->root}`."
-            );
+        if (empty($argv)) {
+            throw new RuntimeException("Cannot run any commands. No arguments received.");
         }
         // Remove the root executable segment
         array_shift($argv);

+ 1 - 19
tests/TestCase/Console/CommandRunnerTest.php

@@ -70,7 +70,7 @@ class CommandRunnerTest extends TestCase
      * Test that running with empty argv fails
      *
      * @expectedException \RuntimeException
-     * @expectedExceptionMessage Unknown root command. Was expecting `cake`
+     * @expectedExceptionMessage Cannot run any commands. No arguments received.
      * @return void
      */
     public function testRunMissingRootCommand()
@@ -88,24 +88,6 @@ class CommandRunnerTest extends TestCase
      * Test that running an unknown command raises an error.
      *
      * @expectedException \RuntimeException
-     * @expectedExceptionMessage Unknown root command `bad`. Was expecting `cake`
-     * @return void
-     */
-    public function testRunInvalidRootCommand()
-    {
-        $app = $this->getMockBuilder(BaseApplication::class)
-            ->setMethods(['middleware', 'bootstrap'])
-            ->setConstructorArgs([$this->config])
-            ->getMock();
-
-        $runner = new CommandRunner($app);
-        $runner->run(['bad', 'i18n']);
-    }
-
-    /**
-     * Test that running an unknown command raises an error.
-     *
-     * @expectedException \RuntimeException
      * @expectedExceptionMessage Unknown command `cake nope`. Run `cake --help` to get the list of valid commands.
      * @return void
      */