8000 Zsh shell autocompletions by adhocore · Pull Request #43970 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

Zsh shell autocompletions #43970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
Add test for zsh shell completions
  • Loading branch information
adhocore committed Nov 9, 2021
commit 0f649dcdf29e8c306acf3125ca87428e81691972
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,54 @@ public function provideCompleteCommandInputDefinitionInputs()
yield 'custom' => [['bin/console', 'hello'], ['Fabien', 'Robin', 'Wouter']];
}

/**
* @dataProvider provideZshCompleteCommandNameInputs
*/
public function testZshCompleteCommandName(array $input, array $suggestions)
{
$this->execute(['--current' => '1', '--input' => $input, '--shell' => 'zsh']);
$this->assertEquals(implode("\n", $suggestions).\PHP_EOL, $this->tester->getDisplay());
}

public function provideZshCompleteCommandNameInputs()
{
yield 'empty' => [['bin/console'], [
'help'."\t".'Display help for a command',
'list'."\t".'List commands',
'completion'."\t".'Dump the shell completion script',
'hello'."\t".'Hello test command',
]];
yield 'partial' => [['bin/console', 'he'], [
'help'."\t".'Display help for a command',
'list'."\t".'List commands',
'completion'."\t".'Dump the shell completion script',
'hello'."\t".'Hello test command',
]];
yield 'complete-shortcut-name' => [['bin/console', 'hell'], ['hello']];
}

/**
* @dataProvider provideZshCompleteCommandInputDefinitionInputs
*/
public function testZshCompleteCommandInputDefinition(array $input, array $suggestions)
{
$this->execute(['--current' => '2', '--input' => $input, '--shell' => 'zsh']);
$this->assertEquals(implode("\n", $suggestions).\PHP_EOL, $this->tester->getDisplay());
}

public function provideZshCompleteCommandInputDefinitionInputs()
{
yield 'definition' => [['bin/console', 'hello', '-'], [
'--help'."\t".'Display help for the given command. When no command is given display help for the list command',
'--quiet'."\t".'Do not output any message',
'--verbose'."\t".'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug',
'--version'."\t".'Display this application version',
'--ansi'."\t".'Force (or disable --no-ansi) ANSI output',
'--no-interaction'."\t".'Do not ask any interactive question',
]];
yield 'custom' => [['bin/console', 'hello'], ['Fabien', 'Robin', 'Wouter']];
}

private function execute(array $input)
{
// run in verbose mode to assert exceptions
Expand All @@ -134,6 +182,7 @@ class CompleteCommandTest_HelloCommand extends Command
public function configure(): void
{
$this->setName('hello')
->setDescription('Hello test command')
->addArgument('name', InputArgument::REQUIRED)
;
}
Expand Down
0