Skip to content

Commit

Permalink
[console] add tests for suggested values (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
seferov authored Jun 20, 2024
1 parent 0f128f9 commit d107a4c
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
42 changes: 41 additions & 1 deletion tests/acceptance/acceptance/console/ConsoleArgument.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ Feature: ConsoleArgument
{
public function configure(): void
{
$this->addArgument('required_string', InputArgument::REQUIRED);
$this->addArgument(
'required_string',
InputArgument::REQUIRED,
'description',
null,
[
'string1',
'string2',
'string3',
]
);
$this->addArgument('required_array', InputArgument::REQUIRED | InputArgument::IS_ARRAY);
}
Expand Down Expand Up @@ -278,3 +288,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

30 changes: 30 additions & 0 deletions tests/acceptance/acceptance/console/ConsoleOption.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d107a4c

Please sign in to comment.