|
14 | 14 | use Symfony\Component\Console\Application;
|
15 | 15 | use Symfony\Component\Console\Helper\HelperSet;
|
16 | 16 | use Symfony\Component\Console\Helper\FormatterHelper;
|
| 17 | +use Symfony\Component\Console\Input\ArgvInput; |
17 | 18 | use Symfony\Component\Console\Input\ArrayInput;
|
18 | 19 | use Symfony\Component\Console\Input\InputInterface;
|
19 | 20 | use Symfony\Component\Console\Input\InputArgument;
|
|
22 | 23 | use Symfony\Component\Console\Output\NullOutput;
|
23 | 24 | use Symfony\Component\Console\Output\Output;
|
24 | 25 | use Symfony\Component\Console\Output\OutputInterface;
|
| 26 | +use Symfony\Component\Console\Output\StreamOutput; |
25 | 27 | use Symfony\Component\Console\Tester\ApplicationTester;
|
26 | 28 | use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
27 | 29 | use Symfony\Component\Console\Event\ConsoleExceptionEvent;
|
@@ -601,6 +603,29 @@ public function testRun()
|
601 | 603 | $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed');
|
602 | 604 | }
|
603 | 605 |
|
| 606 | + /** |
| 607 | + * Issue #9285 |
| 608 | + * |
| 609 | + * If the "verbose" option is just before an argument in ArgvInput, |
| 610 | + * an argument value should not be treated as verbosity value. |
| 611 | + * This test will fail with "Not enough arguments." if broken |
| 612 | + */ |
| 613 | + public function testVerboseValueNotBreakArguments() |
| 614 | + { |
| 615 | + $application = new Application(); |
| 616 | + $application->setAutoExit(false); |
| 617 | + $application->setCatchExceptions(false); |
| 618 | + $application->add(new \FooCommand()); |
| 619 | + |
| 620 | + $output = new StreamOutput(fopen('php://memory', 'w', false)); |
| 621 | + |
| 622 | + $input = new ArgvInput(array('cli.php', '-v', 'foo:bar')); |
| 623 | + $application->run($input, $output); |
| 624 | + |
| 625 | + $input = new ArgvInput(array('cli.php', '--verbose', 'foo:bar')); |
| 626 | + $application->run($input, $output); |
| 627 | + } |
| 628 | + |
604 | 629 | public function testRunReturnsIntegerExitCode()
|
605 | 630 | {
|
606 | 631 | $exception = new \Exception('', 4);
|
|
0 commit comments