Skip to content
Snippets Groups Projects
Unverified Commit 8c347d75 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"

(cherry picked from commit b43aae5d)
parent dd94411b
No related branches found
No related tags found
No related merge requests found
Pipeline #495769 passed
Pipeline: drupal

#495770

    ......@@ -93,11 +93,14 @@ public function collectValue(string $name, DataDefinitionInterface $definition,
    $method = $settings['method'];
    $arguments = $settings['arguments'] ?? [];
    // Most of the input-collecting methods of StyleInterface have a `default`
    // parameter.
    $arguments += [
    'default' => $default_value,
    ];
    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']);
    ......
    ......@@ -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;
    /**
    ......@@ -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);
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment