|
14 | 14 | use PHPUnit\Framework\Assert; |
15 | 15 | use PHPUnit\Framework\Attributes\DataProvider; |
16 | 16 | use PHPUnit\Framework\TestCase; |
| 17 | +use Symfony\Component\Console\Application; |
17 | 18 | use Symfony\Component\Console\Attribute\Argument; |
18 | 19 | use Symfony\Component\Console\Attribute\Option; |
19 | 20 | use Symfony\Component\Console\Command\Command; |
20 | 21 | use Symfony\Component\Console\Completion\CompletionInput; |
21 | 22 | use Symfony\Component\Console\Completion\CompletionSuggestions; |
22 | 23 | use Symfony\Component\Console\Completion\Suggestion; |
| 24 | +use Symfony\Component\Console\Cursor; |
23 | 25 | use Symfony\Component\Console\Exception\InvalidArgumentException; |
24 | 26 | use Symfony\Component\Console\Exception\InvalidOptionException; |
25 | 27 | use Symfony\Component\Console\Exception\LogicException; |
26 | 28 | use Symfony\Component\Console\Input\ArrayInput; |
27 | 29 | use Symfony\Component\Console\Input\InputInterface; |
28 | 30 | use Symfony\Component\Console\Output\NullOutput; |
29 | 31 | use Symfony\Component\Console\Output\OutputInterface; |
| 32 | +use Symfony\Component\Console\Style\SymfonyStyle; |
30 | 33 | use Symfony\Component\Console\Tests\Fixtures\InvokableTestCommand; |
31 | 34 |
|
32 | 35 | class InvokableCommandTest extends TestCase |
@@ -462,6 +465,25 @@ public function testInvalidRequiredValueOptionEvenWithDefault() |
462 | 465 | $command->run(new ArrayInput(['--a' => null]), new NullOutput()); |
463 | 466 | } |
464 | 467 |
|
| 468 | + public function testHelpersInjection() |
| 469 | + { |
| 470 | + $command = new Command('foo'); |
| 471 | + $command->setApplication(new Application()); |
| 472 | + $command->setCode(function ( |
| 473 | + InputInterface $input, |
| 474 | + OutputInterface $output, |
| 475 | + Cursor $cursor, |
| 476 | + SymfonyStyle $io, |
| 477 | + Application $application, |
| 478 | + ): int { |
| 479 | + $this->addToAssertionCount(1); |
| 480 | + |
| 481 | + return 0; |
| 482 | + }); |
| 483 | + |
| 484 | + $command->run(new ArrayInput([]), new NullOutput()); |
| 485 | + } |
| 486 | + |
465 | 487 | public function getSuggestedRoles(CompletionInput $input): array |
466 | 488 | { |
467 | 489 | return ['ROLE_ADMIN', 'ROLE_USER']; |
|
0 commit comments