Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return values instead of keys in discoverCommandsFromConfiguration. (#…
…5039) * Return values instead of keys in discoverCommandsFromConfiguration. * Add testCommandsFromConfiguration test. * Change wording for command not found. * Fix wording one more time and enable commented out tests.
- Loading branch information
Showing
5 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/fixtures/drush-extensions/DrushExtensionsCommands.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Drush\Commands\drush_extensions; | ||
|
||
use Drush\Commands\DrushCommands; | ||
|
||
class DrushExtensionsCommands extends DrushCommands | ||
{ | ||
/** | ||
* Command to load from this file using drush config. | ||
* | ||
* @command drush-extensions-hello | ||
* @bootstrap none | ||
* @hidden | ||
*/ | ||
public function customCommand(): void | ||
{ | ||
$this->io()->text('Hello world!'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Unish; | ||
|
||
/** | ||
* @group commands | ||
*/ | ||
class CommandsFromConfigurationTest extends UnishIntegrationTestCase | ||
{ | ||
/** | ||
* Tests that commands provided by custom libraries are registered. | ||
*/ | ||
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->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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters