Skip to content

Commit

Permalink
Docs: fix SymfonyConsoleJob command parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar committed May 25, 2024
1 parent 9105939 commit a947f25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,9 @@ Command can be parametrized:
```php
$job->setCommandParameters([
'argument' => 'value',
'--option' => 'value',
'--boolean-option' => true,
'--value-option' => 'value',
'--no-value-option' => null,
'--array-value-option' => ['value1', 'value2'],
]);
```

Expand Down
5 changes: 3 additions & 2 deletions tests/Doubles/TestParametrizedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ protected function configure(): void
{
$this->setName('test:parameters');
$this->addArgument('argument', InputArgument::REQUIRED);
$this->addOption('option', null, InputOption::VALUE_REQUIRED);
$this->addOption('bool-option', null, InputOption::VALUE_NONE);
$this->addOption('value-option', null, InputOption::VALUE_REQUIRED);
$this->addOption('no-value-option', null, InputOption::VALUE_NONE);
$this->addOption('array-value-option', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED);
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand Down
10 changes: 6 additions & 4 deletions tests/Unit/Job/SymfonyConsoleJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,15 @@ public function testCommandParameters(): void
$application->add($command);
$job = new SymfonyConsoleJob($command, $application);
$job->setCommandParameters([
'argument' => 'a',
'--option' => 'b',
'--bool-option' => true,
'argument' => 'value',
'--value-option' => 'value',
'--no-value-option' => null,
'--array-value-option' => ['value1', 'value2'],
]);

self::assertStringMatchesFormat(
'symfony/console: %ctest:parameters%c a --option=b --bool-option=1',
'symfony/console: %ctest:parameters%c'
. ' value --value-option=value --no-value-option --array-value-option=value1 --array-value-option=value2',
$job->getName(),
);

Expand Down

0 comments on commit a947f25

Please sign in to comment.