Skip to content
Snippets Groups Projects
Unverified Commit b43aae5d authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3517481 by mradcliffe, smustgrave: askHidden prompt fails with "Unknown...

Issue #3517481 by mradcliffe, smustgrave: askHidden prompt fails with "Unknown named parameter $default"
parent e298fb7b
Branches
Tags
2 merge requests!5423Draft: Resolve #3329907 "Test2",!3478Issue #3337882: Deleted menus are not removed from content type config
Pipeline #495743 passed with warnings
Pipeline: drupal

#495766

    Pipeline: drupal

    #495753

      Pipeline: drupal

      #495748

        ...@@ -93,11 +93,14 @@ public function collectValue(string $name, DataDefinitionInterface $definition, ...@@ -93,11 +93,14 @@ public function collectValue(string $name, DataDefinitionInterface $definition,
        $method = $settings['method']; $method = $settings['method'];
        $arguments = $settings['arguments'] ?? []; $arguments = $settings['arguments'] ?? [];
        // Most of the input-collecting methods of StyleInterface have a `default` if ($method !== 'askHidden') {
        // parameter. // Most of the input-collecting methods of StyleInterface have a `default`
        $arguments += [ // parameter.
        'default' => $default_value, $arguments += [
        ]; 'default' => $default_value,
        ];
        }
        // We don't support using Symfony Console's inline validation; instead, // We don't support using Symfony Console's inline validation; instead,
        // input definitions should define constraints. // input definitions should define constraints.
        unset($arguments['validator']); unset($arguments['validator']);
        ......
        ...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
        use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
        use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
        use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
        use Symfony\Component\Console\Output\OutputInterface;
        use Symfony\Component\Console\Style\StyleInterface; use Symfony\Component\Console\Style\StyleInterface;
        use Symfony\Component\Console\Style\SymfonyStyle;
        use Symfony\Component\Validator\Exception\ValidationFailedException; use Symfony\Component\Validator\Exception\ValidationFailedException;
        /** /**
        ...@@ -289,4 +291,32 @@ public function collectValue(string $name, DataDefinitionInterface $definition, ...@@ -289,4 +291,32 @@ public function collectValue(string $name, DataDefinitionInterface $definition,
        RecipeRunner::processRecipe($recipe); 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);
        }
        } }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment