Browse Source

Ensure VersionCommand class is available.

It won't be available when using just console package.
ADmad 6 years ago
parent
commit
e6120cf24d
2 changed files with 4 additions and 2 deletions
  1. 3 1
      src/Console/CommandRunner.php
  2. 1 1
      tests/TestCase/Console/CommandRunnerTest.php

+ 3 - 1
src/Console/CommandRunner.php

@@ -132,9 +132,11 @@ class CommandRunner implements EventDispatcherInterface
         $this->bootstrap();
 
         $commands = new CommandCollection([
-            'version' => VersionCommand::class,
             'help' => HelpCommand::class,
         ]);
+        if (class_exists(VersionCommand::class)) {
+            $commands->add('version', VersionCommand::class);
+        }
         $commands = $this->app->console($commands);
 
         if ($this->app instanceof PluginApplicationInterface) {

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

@@ -164,7 +164,7 @@ class CommandRunnerTest extends TestCase
             "\n" .
             "Other valid choices:\n" .
             "\n" .
-            "- version",
+            "- help",
             $messages
         );
     }