Loading core/lib/Drupal/Core/Recipe/ConsoleInputCollector.php +8 −5 Original line number Diff line number Diff line Loading @@ -93,11 +93,14 @@ public function collectValue(string $name, DataDefinitionInterface $definition, $method = $settings['method']; $arguments = $settings['arguments'] ?? []; if ($method !== 'askHidden') { // Most of the input-collecting methods of StyleInterface have a `default` // parameter. $arguments += [ 'default' => $default_value, ]; } // We don't support using Symfony Console's inline validation; instead, // input definitions should define constraints. unset($arguments['validator']); Loading core/tests/Drupal/KernelTests/Core/Recipe/InputTest.php +30 −0 Original line number Diff line number Diff line Loading @@ -17,7 +17,9 @@ use Drupal\KernelTests\KernelTestBase; use Drupal\node\Entity\NodeType; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\StyleInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Validator\Exception\ValidationFailedException; /** Loading Loading @@ -272,4 +274,32 @@ public function collectValue(string $name, DataDefinitionInterface $definition, RecipeRunner::processRecipe($recipe); } /** * Tests that the askHidden prompt forwards arguments correctly. */ public function testAskHiddenPromptArgumentsForwarded(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); $io = new SymfonyStyle($input, $output); $recipe = $this->createRecipe(<<<YAML name: 'Prompt askHidden Test' input: foo: data_type: string description: Foo prompt: method: askHidden default: source: value value: bar YAML ); $collector = new ConsoleInputCollector($input, $io); // askHidden prompt should have an ArgumentCountError rather than a general // error. $this->expectException(\ArgumentCountError::class); $recipe->input->collectAll($collector); } } Loading
core/lib/Drupal/Core/Recipe/ConsoleInputCollector.php +8 −5 Original line number Diff line number Diff line Loading @@ -93,11 +93,14 @@ public function collectValue(string $name, DataDefinitionInterface $definition, $method = $settings['method']; $arguments = $settings['arguments'] ?? []; if ($method !== 'askHidden') { // Most of the input-collecting methods of StyleInterface have a `default` // parameter. $arguments += [ 'default' => $default_value, ]; } // We don't support using Symfony Console's inline validation; instead, // input definitions should define constraints. unset($arguments['validator']); Loading
core/tests/Drupal/KernelTests/Core/Recipe/InputTest.php +30 −0 Original line number Diff line number Diff line Loading @@ -17,7 +17,9 @@ use Drupal\KernelTests\KernelTestBase; use Drupal\node\Entity\NodeType; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\StyleInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Validator\Exception\ValidationFailedException; /** Loading Loading @@ -272,4 +274,32 @@ public function collectValue(string $name, DataDefinitionInterface $definition, RecipeRunner::processRecipe($recipe); } /** * Tests that the askHidden prompt forwards arguments correctly. */ public function testAskHiddenPromptArgumentsForwarded(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); $io = new SymfonyStyle($input, $output); $recipe = $this->createRecipe(<<<YAML name: 'Prompt askHidden Test' input: foo: data_type: string description: Foo prompt: method: askHidden default: source: value value: bar YAML ); $collector = new ConsoleInputCollector($input, $io); // askHidden prompt should have an ArgumentCountError rather than a general // error. $this->expectException(\ArgumentCountError::class); $recipe->input->collectAll($collector); } }