public function ApplicationTest::testRun in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Tests/ApplicationTest.php \Symfony\Component\Console\Tests\ApplicationTest::testRun()
File
- vendor/
symfony/ console/ Tests/ ApplicationTest.php, line 589
Class
Namespace
Symfony\Component\Console\TestsCode
public function testRun() {
$application = new Application();
$application
->setAutoExit(false);
$application
->setCatchExceptions(false);
$application
->add($command = new \Foo1Command());
$_SERVER['argv'] = array(
'cli.php',
'foo:bar1',
);
ob_start();
$application
->run();
ob_end_clean();
$this
->assertInstanceOf('Symfony\\Component\\Console\\Input\\ArgvInput', $command->input, '->run() creates an ArgvInput by default if none is given');
$this
->assertInstanceOf('Symfony\\Component\\Console\\Output\\ConsoleOutput', $command->output, '->run() creates a ConsoleOutput by default if none is given');
$application = new Application();
$application
->setAutoExit(false);
$application
->setCatchExceptions(false);
$this
->ensureStaticCommandHelp($application);
$tester = new ApplicationTester($application);
$tester
->run(array(), array(
'decorated' => false,
));
$this
->assertStringEqualsFile(self::$fixturesPath . '/application_run1.txt', $tester
->getDisplay(true), '->run() runs the list command if no argument is passed');
$tester
->run(array(
'--help' => true,
), array(
'decorated' => false,
));
$this
->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $tester
->getDisplay(true), '->run() runs the help command if --help is passed');
$tester
->run(array(
'-h' => true,
), array(
'decorated' => false,
));
$this
->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $tester
->getDisplay(true), '->run() runs the help command if -h is passed');
$tester
->run(array(
'command' => 'list',
'--help' => true,
), array(
'decorated' => false,
));
$this
->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $tester
->getDisplay(true), '->run() displays the help if --help is passed');
$tester
->run(array(
'command' => 'list',
'-h' => true,
), array(
'decorated' => false,
));
$this
->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $tester
->getDisplay(true), '->run() displays the help if -h is passed');
$tester
->run(array(
'--ansi' => true,
));
$this
->assertTrue($tester
->getOutput()
->isDecorated(), '->run() forces color output if --ansi is passed');
$tester
->run(array(
'--no-ansi' => true,
));
$this
->assertFalse($tester
->getOutput()
->isDecorated(), '->run() forces color output to be disabled if --no-ansi is passed');
$tester
->run(array(
'--version' => true,
), array(
'decorated' => false,
));
$this
->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $tester
->getDisplay(true), '->run() displays the program version if --version is passed');
$tester
->run(array(
'-V' => true,
), array(
'decorated' => false,
));
$this
->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $tester
->getDisplay(true), '->run() displays the program version if -v is passed');
$tester
->run(array(
'command' => 'list',
'--quiet' => true,
));
$this
->assertSame('', $tester
->getDisplay(), '->run() removes all output if --quiet is passed');
$tester
->run(array(
'command' => 'list',
'-q' => true,
));
$this
->assertSame('', $tester
->getDisplay(), '->run() removes all output if -q is passed');
$tester
->run(array(
'command' => 'list',
'--verbose' => true,
));
$this
->assertSame(Output::VERBOSITY_VERBOSE, $tester
->getOutput()
->getVerbosity(), '->run() sets the output to verbose if --verbose is passed');
$tester
->run(array(
'command' => 'list',
'--verbose' => 1,
));
$this
->assertSame(Output::VERBOSITY_VERBOSE, $tester
->getOutput()
->getVerbosity(), '->run() sets the output to verbose if --verbose=1 is passed');
$tester
->run(array(
'command' => 'list',
'--verbose' => 2,
));
$this
->assertSame(Output::VERBOSITY_VERY_VERBOSE, $tester
->getOutput()
->getVerbosity(), '->run() sets the output to very verbose if --verbose=2 is passed');
$tester
->run(array(
'command' => 'list',
'--verbose' => 3,
));
$this
->assertSame(Output::VERBOSITY_DEBUG, $tester
->getOutput()
->getVerbosity(), '->run() sets the output to debug if --verbose=3 is passed');
$tester
->run(array(
'command' => 'list',
'--verbose' => 4,
));
$this
->assertSame(Output::VERBOSITY_VERBOSE, $tester
->getOutput()
->getVerbosity(), '->run() sets the output to verbose if unknown --verbose level is passed');
$tester
->run(array(
'command' => 'list',
'-v' => true,
));
$this
->assertSame(Output::VERBOSITY_VERBOSE, $tester
->getOutput()
->getVerbosity(), '->run() sets the output to verbose if -v is passed');
$tester
->run(array(
'command' => 'list',
'-vv' => true,
));
$this
->assertSame(Output::VERBOSITY_VERY_VERBOSE, $tester
->getOutput()
->getVerbosity(), '->run() sets the output to verbose if -v is passed');
$tester
->run(array(
'command' => 'list',
'-vvv' => true,
));
$this
->assertSame(Output::VERBOSITY_DEBUG, $tester
->getOutput()
->getVerbosity(), '->run() sets the output to verbose if -v is passed');
$application = new Application();
$application
->setAutoExit(false);
$application
->setCatchExceptions(false);
$application
->add(new \FooCommand());
$tester = new ApplicationTester($application);
$tester
->run(array(
'command' => 'foo:bar',
'--no-interaction' => true,
), array(
'decorated' => false,
));
$this
->assertSame('called' . PHP_EOL, $tester
->getDisplay(), '->run() does not call interact() if --no-interaction is passed');
$tester
->run(array(
'command' => 'foo:bar',
'-n' => true,
), array(
'decorated' => false,
));
$this
->assertSame('called' . PHP_EOL, $tester
->getDisplay(), '->run() does not call interact() if -n is passed');
}