restore previous testing style with static fixtures for console
This commit is contained in:
parent
11585c3b67
commit
447d46814c
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Tests\Component\Console;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@ -359,27 +358,27 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame('Symfony\Component\Console\Input\ArgvInput', get_class($command->input), '->run() creates an ArgvInput by default if none is given');
|
||||
$this->assertSame('Symfony\Component\Console\Output\ConsoleOutput', get_class($command->output), '->run() creates a ConsoleOutput by default if none is given');
|
||||
|
||||
$formatter = new OutputFormatter(false);
|
||||
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->setCatchExceptions(false);
|
||||
|
||||
$this->ensureStaticCommandHelp($application);
|
||||
$tester = new ApplicationTester($application);
|
||||
|
||||
$tester->run(array(), array('decorated' => false));
|
||||
$this->assertSame($formatter->format($application->asText()).PHP_EOL, $tester->getDisplay(), '->run() runs the list command if no argument is passed');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run1.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->run() runs the list command if no argument is passed');
|
||||
|
||||
$tester->run(array('--help' => true), array('decorated' => false));
|
||||
$this->assertSame($formatter->format($application->get('help')->asText()).PHP_EOL, $tester->getDisplay(), '->run() runs the help command if --help is passed');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->run() runs the help command if --help is passed');
|
||||
|
||||
$tester->run(array('-h' => true), array('decorated' => false));
|
||||
$this->assertSame($formatter->format($application->get('help')->asText()).PHP_EOL, $tester->getDisplay(), '->run() runs the help command if -h is passed');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->run() runs the help command if -h is passed');
|
||||
|
||||
$tester->run(array('command' => 'list', '--help' => true), array('decorated' => false));
|
||||
$this->assertSame($formatter->format($application->get('list')->asText()).PHP_EOL, $tester->getDisplay(), '->run() displays the help if --help is passed');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->run() displays the help if --help is passed');
|
||||
|
||||
$tester->run(array('command' => 'list', '-h' => true), array('decorated' => false));
|
||||
$this->assertSame($formatter->format($application->get('list')->asText()).PHP_EOL, $tester->getDisplay(), '->run() displays the help if -h is passed');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->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');
|
||||
@ -388,10 +387,10 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
$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->assertSame($formatter->format($application->getLongVersion()).PHP_EOL, $tester->getDisplay(), '->run() displays the program version if --version is passed');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->run() displays the program version if --version is passed');
|
||||
|
||||
$tester->run(array('-V' => true), array('decorated' => false));
|
||||
$this->assertSame($formatter->format($application->getLongVersion()).PHP_EOL, $tester->getDisplay(), '->run() displays the program version if -V is passed');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->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');
|
||||
|
@ -0,0 +1,17 @@
|
||||
Console Tool
|
||||
|
||||
Usage:
|
||||
[options] command [arguments]
|
||||
|
||||
Options:
|
||||
--help -h Display this help message.
|
||||
--quiet -q Do not output any message.
|
||||
--verbose -v Increase verbosity of messages.
|
||||
--version -V Display this application version.
|
||||
--ansi Force ANSI output.
|
||||
--no-ansi Disable ANSI output.
|
||||
--no-interaction -n Do not ask any interactive question.
|
||||
|
||||
Available commands:
|
||||
help Displays help for a command
|
||||
list Lists commands
|
@ -0,0 +1,26 @@
|
||||
Usage:
|
||||
help [--xml] [command_name]
|
||||
|
||||
Arguments:
|
||||
command The command to execute
|
||||
command_name The command name (default: 'help')
|
||||
|
||||
Options:
|
||||
--xml To output help as XML
|
||||
--help (-h) Display this help message.
|
||||
--quiet (-q) Do not output any message.
|
||||
--verbose (-v) Increase verbosity of messages.
|
||||
--version (-V) Display this application version.
|
||||
--ansi Force ANSI output.
|
||||
--no-ansi Disable ANSI output.
|
||||
--no-interaction (-n) Do not ask any interactive question.
|
||||
|
||||
Help:
|
||||
The help command displays help for a given command:
|
||||
|
||||
php app/console help list
|
||||
|
||||
You can also output the help as XML by using the --xml option:
|
||||
|
||||
php app/console help --xml list
|
||||
|
@ -0,0 +1,27 @@
|
||||
Usage:
|
||||
list [--xml] [--raw] [namespace]
|
||||
|
||||
Arguments:
|
||||
namespace The namespace name
|
||||
|
||||
Options:
|
||||
--xml To output help as XML
|
||||
--raw To output raw command list
|
||||
|
||||
Help:
|
||||
The list command lists all commands:
|
||||
|
||||
php app/console list
|
||||
|
||||
You can also display the commands for a specific namespace:
|
||||
|
||||
php app/console list test
|
||||
|
||||
You can also output the information as XML by using the --xml option:
|
||||
|
||||
php app/console list --xml
|
||||
|
||||
It's also possible to get raw list of commands (useful for embedding command runner):
|
||||
|
||||
php app/console list --raw
|
||||
|
@ -0,0 +1 @@
|
||||
Console Tool
|
Reference in New Issue
Block a user