Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5e03e9a

Browse files
committed
[Console] Add test for --verbose before argument
1 parent e49ca36 commit 5e03e9a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Console\Application;
1515
use Symfony\Component\Console\Helper\HelperSet;
1616
use Symfony\Component\Console\Helper\FormatterHelper;
17+
use Symfony\Component\Console\Input\ArgvInput;
1718
use Symfony\Component\Console\Input\ArrayInput;
1819
use Symfony\Component\Console\Input\InputInterface;
1920
use Symfony\Component\Console\Input\InputArgument;
@@ -22,6 +23,7 @@
2223
use Symfony\Component\Console\Output\NullOutput;
2324
use Symfony\Component\Console\Output\Output;
2425
use Symfony\Component\Console\Output\OutputInterface;
26+
use Symfony\Component\Console\Output\StreamOutput;
2527
use Symfony\Component\Console\Tester\ApplicationTester;
2628
use Symfony\Component\Console\Event\ConsoleCommandEvent;
2729
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
@@ -601,6 +603,29 @@ public function testRun()
601603
$this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed');
602604
}
603605

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+
604629
public function testRunReturnsIntegerExitCode()
605630
{
606631
$exception = new \Exception('', 4);

0 commit comments

Comments
 (0)