From 213934eb8034f93623c0a7f8e20fafec73a20c30 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Fri, 21 Jan 2022 15:20:33 -0600 Subject: [PATCH 1/4] Return values instead of keys in discoverCommandsFromConfiguration. --- src/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); } /** From 3b1eac4d71a60fb3875de984d7aeeab1c26e84ee Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Mon, 24 Jan 2022 15:15:23 -0600 Subject: [PATCH 2/4] Add testCommandsFromConfiguration test. --- .../DrushExtensionsCommands.php | 20 ++++++++++++++ tests/fixtures/drush-extensions/drush.yml | 8 ++++++ .../CommandsFromConfigurationTest.php | 27 +++++++++++++++++++ tests/unish/UnishTestCase.php | 1 + 4 files changed, 56 insertions(+) create mode 100644 tests/fixtures/drush-extensions/DrushExtensionsCommands.php create mode 100644 tests/fixtures/drush-extensions/drush.yml create mode 100644 tests/integration/CommandsFromConfigurationTest.php 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..4cb6914c89 --- /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 was not found.', $this->getErrorOutput()); + $this->drush('drush-extensions-hello', [], [ + 'help' => null, + 'config' => '/Users/kporras07/development/pantheon/drush/tests/fixtures/drush-extensions/drush.yml', + ]); + $this->assertStringContainsString('Command to load from this file using drush config.', $this->getOutput()); + /*$this->drush('drush-extensions-hello', [], [ + 'config' => '/Users/kporras07/development/pantheon/drush/tests/fixtures/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')]); } /** From 25ebaf1f877bcf98e3fd72860dedb35e204a35af Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Mon, 24 Jan 2022 15:26:56 -0600 Subject: [PATCH 3/4] Change wording for command not found. --- tests/integration/CommandsFromConfigurationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/CommandsFromConfigurationTest.php b/tests/integration/CommandsFromConfigurationTest.php index 4cb6914c89..9e38aedbc5 100644 --- a/tests/integration/CommandsFromConfigurationTest.php +++ b/tests/integration/CommandsFromConfigurationTest.php @@ -13,7 +13,7 @@ class CommandsFromConfigurationTest extends UnishIntegrationTestCase public function testCommandsFromConfiguration(): void { $this->drush('drush-extensions-hello', [], ['help' => null], self::EXIT_ERROR); - $this->assertStringContainsString('Command drush-extensions-hello was not found.', $this->getErrorOutput()); + $this->assertStringContainsString('Command drush-extensions-hello is not defined.', $this->getErrorOutput()); $this->drush('drush-extensions-hello', [], [ 'help' => null, 'config' => '/Users/kporras07/development/pantheon/drush/tests/fixtures/drush-extensions/drush.yml', From cb0beb635f21c31b158c11f98c16e9904f749610 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Mon, 24 Jan 2022 15:40:02 -0600 Subject: [PATCH 4/4] Fix wording one more time and enable commented out tests. --- tests/integration/CommandsFromConfigurationTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integration/CommandsFromConfigurationTest.php b/tests/integration/CommandsFromConfigurationTest.php index 9e38aedbc5..021c44f8c4 100644 --- a/tests/integration/CommandsFromConfigurationTest.php +++ b/tests/integration/CommandsFromConfigurationTest.php @@ -13,15 +13,15 @@ class CommandsFromConfigurationTest extends UnishIntegrationTestCase public function testCommandsFromConfiguration(): void { $this->drush('drush-extensions-hello', [], ['help' => null], self::EXIT_ERROR); - $this->assertStringContainsString('Command drush-extensions-hello is not defined.', $this->getErrorOutput()); + $this->assertStringContainsString('Command "drush-extensions-hello" is not defined.', $this->getErrorOutput()); $this->drush('drush-extensions-hello', [], [ 'help' => null, - 'config' => '/Users/kporras07/development/pantheon/drush/tests/fixtures/drush-extensions/drush.yml', + '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' => '/Users/kporras07/development/pantheon/drush/tests/fixtures/drush-extensions/drush.yml', + $this->drush('drush-extensions-hello', [], [ + 'config' => getenv('FIXTURES_DIR') . '/drush-extensions/drush.yml', ]); - $this->assertStringContainsString('Hello world!', $this->getOutput());*/ + $this->assertStringContainsString('Hello world!', $this->getOutput()); } }