function InputTest::testPromptArgumentsAreForwarded
@covers \Drupal\Core\Recipe\ConsoleInputCollector::collectValue
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Recipe/ InputTest.php, line 90
Class
- InputTest
- @group Recipe @covers \Drupal\Core\Recipe\InputConfigurator
Namespace
Drupal\KernelTests\Core\RecipeCode
public function testPromptArgumentsAreForwarded() : void {
$io = $this->createMock(StyleInterface::class);
$io->expects($this->once())
->method('ask')
->with('What is the capital of Assyria?', "I don't know that!")
->willReturn('<scream>');
$recipe = $this->createRecipe(<<<YAML
name: 'Collecting prompt input'
input:
capital:
data_type: string
description: The capital of a long-defunct country.
prompt:
method: ask
arguments:
question: What is the capital of Assyria?
# This argument should be discarded.
validator: 'test_validator'
default:
source: value
value: "I don't know that!"
YAML
);
$collector = new ConsoleInputCollector($this->createMock(InputInterface::class), $io);
$recipe->input
->collectAll($collector);
$this->assertSame([
'capital' => '<scream>',
], $recipe->input
->getValues());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.