Example #1
0
    $tester->run(array('command' => 'foo'));
    $t->fail('->setCatchExceptions() sets the catch exception flag');
} catch (\Exception $e) {
    $t->pass('->setCatchExceptions() sets the catch exception flag');
}
// ->asText()
$t->diag('->asText()');
$application = new Application();
$application->addCommand(new FooCommand());
$t->is($application->asText(), file_get_contents($fixtures . '/application_astext1.txt'), '->asText() returns a text representation of the application');
$t->is($application->asText('foo'), file_get_contents($fixtures . '/application_astext2.txt'), '->asText() returns a text representation of the application');
// ->asXml()
$t->diag('->asXml()');
$application = new Application();
$application->addCommand(new FooCommand());
$t->is($application->asXml(), file_get_contents($fixtures . '/application_asxml1.txt'), '->asXml() returns an XML representation of the application');
$t->is($application->asXml('foo'), file_get_contents($fixtures . '/application_asxml2.txt'), '->asXml() returns an XML representation of the application');
// ->renderException()
$t->diag('->renderException()');
$application = new Application();
$application->setAutoExit(false);
$tester = new ApplicationTester($application);
$tester->run(array('command' => 'foo'));
$t->is($tester->getDisplay(), file_get_contents($fixtures . '/application_renderexception1.txt'), '->renderException() renders a pretty exception');
$tester->run(array('command' => 'foo'), array('verbosity' => Output::VERBOSITY_VERBOSE));
$t->like($tester->getDisplay(), '/Exception trace/', '->renderException() renders a pretty exception with a stack trace when verbosity is verbose');
$tester->run(array('command' => 'list', '--foo' => true));
$t->is($tester->getDisplay(), file_get_contents($fixtures . '/application_renderexception2.txt'), '->renderException() renders the command synopsis when an exception occurs in the context of a command');
// ->run()
$t->diag('->run()');
$application = new Application();