diff --git a/src/Application.php b/src/Application.php index c54da5ef30..d5ce79a167 100644 --- a/src/Application.php +++ b/src/Application.php @@ -351,7 +351,7 @@ protected function discoverCommandsFromConfiguration() } } $this->loadCommandClasses($commandList); - return array_keys($commandList); + return array_values($commandList); } /** diff --git a/tests/fixtures/drush-extensions/DrushExtensionsCommands.php b/tests/fixtures/drush-extensions/DrushExtensionsCommands.php new file mode 100644 index 0000000000..2800829b32 --- /dev/null +++ b/tests/fixtures/drush-extensions/DrushExtensionsCommands.php @@ -0,0 +1,20 @@ +io()->text('Hello world!'); + } +} diff --git a/tests/fixtures/drush-extensions/drush.yml b/tests/fixtures/drush-extensions/drush.yml new file mode 100644 index 0000000000..17a3d4c09f --- /dev/null +++ b/tests/fixtures/drush-extensions/drush.yml @@ -0,0 +1,8 @@ +# +# Drush configuration file used to configure the System Unter Test (sut) +# +# Docs at https://github.com/drush-ops/drush/blob/master/examples/example.drush.yml +# +drush: + commands: + '\Drush\Commands\drush_extensions\DrushExtensionsCommands': '${env.FIXTURES_DIR}/drush-extensions/DrushExtensionsCommands.php' \ No newline at end of file diff --git a/tests/integration/CommandsFromConfigurationTest.php b/tests/integration/CommandsFromConfigurationTest.php new file mode 100644 index 0000000000..021c44f8c4 --- /dev/null +++ b/tests/integration/CommandsFromConfigurationTest.php @@ -0,0 +1,27 @@ +drush('drush-extensions-hello', [], ['help' => null], self::EXIT_ERROR); + $this->assertStringContainsString('Command "drush-extensions-hello" is not defined.', $this->getErrorOutput()); + $this->drush('drush-extensions-hello', [], [ + 'help' => null, + 'config' => getenv('FIXTURES_DIR') . '/drush-extensions/drush.yml', + ]); + $this->assertStringContainsString('Command to load from this file using drush config.', $this->getOutput()); + $this->drush('drush-extensions-hello', [], [ + 'config' => getenv('FIXTURES_DIR') . '/drush-extensions/drush.yml', + ]); + $this->assertStringContainsString('Hello world!', $this->getOutput()); + } +} diff --git a/tests/unish/UnishTestCase.php b/tests/unish/UnishTestCase.php index 2ce0861507..48d7e2d6a0 100644 --- a/tests/unish/UnishTestCase.php +++ b/tests/unish/UnishTestCase.php @@ -71,6 +71,7 @@ public function __construct($name = null, array $data = [], $dataName = '') self::setEnv(['ETC_PREFIX' => $unish_sandbox]); self::setEnv(['SHARE_PREFIX' => $unish_sandbox]); self::setEnv(['TEMP' => Path::join($unish_sandbox, 'tmp')]); + self::setEnv(['FIXTURES_DIR' => Path::join(dirname(__DIR__), 'fixtures')]); } /**