$knownWords =
['Carrot', 'Creme', 'Curry', 'Parsnip', 'Pie', 'Potato', 'Tart'
];
$inputWords =
explode(' ',
$input);
array_pop($inputWords);
$suggestionBase =
$inputWords ?
implode(' ',
$inputWords).' ' : '';
return array_map( fn ($word) =>
$suggestionBase.
$word.' ',
$knownWords );
};
$question->
setAutocompleterCallback($callback);
$this->
assertSame('Potato Creme Pie',
$dialog->
ask($this->
createStreamableInputInterfaceMock($inputStream),
$this->
createOutputInterface(),
$question));
} public function testAskWithAutocompleteWithNonSequentialKeys() { if (!Terminal::
hasSttyAvailable()) { $this->
markTestSkipped('`stty` is required to test autocomplete functionality'
);
} // <UP ARROW><UP ARROW><NEWLINE><DOWN ARROW><DOWN ARROW><NEWLINE>