$this->
expectException(LogicException::
class);
$this->
expectExceptionMessage('Cannot set suggested values if the option does not accept a value.'
);
new InputOption('foo', null, InputOption::VALUE_NONE, '', null,
['foo'
]);
} public function testCompleteArray() { $values =
['foo', 'bar'
];
$option =
new InputOption('foo', null, InputOption::VALUE_OPTIONAL, '', null,
$values);
$this->
assertTrue($option->
hasCompletion());
$suggestions =
new CompletionSuggestions();
$option->
complete(new CompletionInput(),
$suggestions);
$this->
assertSame($values,
array_map(fn (Suggestion
$suggestion) =>
$suggestion->
getValue(),
$suggestions->
getValueSuggestions()));
} public function testCompleteClosure() { $values =
['foo', 'bar'
];
$option =
new InputOption('foo', null, InputOption::VALUE_OPTIONAL, '', null,
fn (CompletionInput
$input): array =>
$values);
$this->
assertTrue($option->
hasCompletion());
$suggestions =
new CompletionSuggestions();
$option->
complete(new CompletionInput(),
$suggestions);