From 10e59e10c1270f554b0c5d0a643b1ed30f3017a1 Mon Sep 17 00:00:00 2001 From: Farhad Safarov Date: Wed, 19 Jun 2024 10:20:14 +0300 Subject: [PATCH] [console] add tests for suggested values --- .../console/ConsoleArgument.feature | 30 +++++++++++++++++++ .../acceptance/console/ConsoleOption.feature | 30 +++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/tests/acceptance/acceptance/console/ConsoleArgument.feature b/tests/acceptance/acceptance/console/ConsoleArgument.feature index 4b329c9..9ffacd2 100644 --- a/tests/acceptance/acceptance/console/ConsoleArgument.feature +++ b/tests/acceptance/acceptance/console/ConsoleArgument.feature @@ -278,3 +278,33 @@ Feature: ConsoleArgument | Type | Message | | Trace | $arg: null\|string | And I see no other errors + + Scenario: Use suggested values for argument + Given I have the following code + """ + class MyCommand extends Command + { + public function configure(): void + { + $this->addArgument( + 'format', + InputArgument::OPTIONAL, + 'The format to use', + null, + [ + 'pdf', + 'excel', + 'csv', + ], + ); + } + + public function execute(InputInterface $input, OutputInterface $output): int + { + return self::SUCCESS; + } + } + """ + When I run Psalm + Then I see no errors + diff --git a/tests/acceptance/acceptance/console/ConsoleOption.feature b/tests/acceptance/acceptance/console/ConsoleOption.feature index 35e759c..4bf20e6 100644 --- a/tests/acceptance/acceptance/console/ConsoleOption.feature +++ b/tests/acceptance/acceptance/console/ConsoleOption.feature @@ -297,3 +297,33 @@ Feature: ConsoleOption | MixedAssignment | Unable to determine the type that $option is being assigned to | | Trace | $option: mixed | And I see no other errors + + Scenario: Using suggested values for option + Given I have the following code + """ + class MyCommand extends Command + { + public function configure(): void + { + $this->addOption( + 'format', + null, + InputOption::VALUE_OPTIONAL, + 'The format to use', + null, + [ + 'pdf', + 'excel', + 'csv', + ], + ); + } + + public function execute(InputInterface $input, OutputInterface $output): int + { + return self::SUCCESS; + } + } + """ + When I run Psalm + Then I see no errors