Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[console] add tests for suggested values #349

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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