-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from stecman/conflicting-options
Prevent global/application options conflicting with CompletionCommand
- Loading branch information
Showing
2 changed files
with
87 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
41 changes: 41 additions & 0 deletions
41
tests/Stecman/Component/Symfony/Console/BashCompletion/CompletionCommandTest.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,41 @@ | ||
<?php | ||
|
||
namespace Stecman\Component\Symfony\Console\BashCompletion\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand; | ||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\StringInput; | ||
use Symfony\Component\Console\Output\NullOutput; | ||
|
||
class CompletionCommandTest extends TestCase | ||
{ | ||
/** | ||
* Ensure conflicting options names and shortcuts from the application do not break the completion command | ||
*/ | ||
public function testConflictingGlobalOptions() | ||
{ | ||
$app = new Application('Base application'); | ||
|
||
// Conflicting option shortcut | ||
$app->getDefinition()->addOption( | ||
new InputOption('conflicting-shortcut', 'g', InputOption::VALUE_NONE) | ||
); | ||
|
||
// Conflicting option name | ||
$app->getDefinition()->addOption( | ||
new InputOption('program', null, InputOption::VALUE_REQUIRED) | ||
); | ||
|
||
$app->add(new CompletionCommand()); | ||
|
||
// Check completion command doesn't throw | ||
$app->doRun(new StringInput('_completion -g --program foo'), new NullOutput()); | ||
$app->doRun(new StringInput('_completion --help'), new NullOutput()); | ||
$app->doRun(new StringInput('help _completion'), new NullOutput()); | ||
|
||
// Check default options are available | ||
$app->doRun(new StringInput('_completion -V -vv --no-ansi --quiet'), new NullOutput()); | ||
} | ||
} |