merged branch Tobion/command-name (PR #3285)
Commits -------447d468
restore previous testing style with static fixtures for console11585c3
fix Command:asXml to use processed help304e13d
replaced command names with supported placeholders in help texts Discussion ---------- using the placeholder in command help texts Replaced the command names with the already supported placeholders `%command.name%` and `%command.full_name%`. Thus preventing typos in future commands based on the existing ones. --------------------------------------------------------------------------- by fabpot at 2012-02-09T06:26:07Z That breaks the unit tests. --------------------------------------------------------------------------- by Tobion at 2012-02-09T17:05:06Z fixed --------------------------------------------------------------------------- by stof at 2012-02-09T17:43:47Z can you rebase your branch please ? it conflicts with master --------------------------------------------------------------------------- by stof at 2012-02-09T17:44:11Z the reason is simple: SwiftmailerBundle is gone :) --------------------------------------------------------------------------- by Tobion at 2012-02-09T23:23:23Z done --------------------------------------------------------------------------- by fabpot at 2012-02-11T23:47:10Z Can you squash your commit before I merge this PR? Thanks. --------------------------------------------------------------------------- by Tobion at 2012-02-12T13:57:14Z I'm unable to squash it into 1 commit because of the uptream commits inside. I hope it's fine now. If not someone needs to help me. --------------------------------------------------------------------------- by stof at 2012-02-12T14:27:38Z ``git rebase -i upstream/master`` should allow you rebasing things and squashing them toghter (changing the action for the second commit to ``squash``) --------------------------------------------------------------------------- by Tobion at 2012-02-12T14:47:29Z first i tried with git rebase -i head~4 (4 commits), but this showed many more external commits. second I tried git reset --soft with a clean commit, but still no success. then I used your proposal. and there are always conflicts of stuff that is not part of my PR. now the diff is messed up... this is frustrating --------------------------------------------------------------------------- by stof at 2012-02-12T14:58:43Z The only reason why the diff is messed is because you messed it when resolving the conflicts by choosing the wrong result for the output. Please fix things as it means that merging your PR would revert changes done previosuly --------------------------------------------------------------------------- by stof at 2012-02-12T15:00:18Z Basically, you reverted most of the changes done in Symfony the few last days. --------------------------------------------------------------------------- by Tobion at 2012-02-12T15:10:59Z I used `git checkout --theirs .` when resolving. Whats the correct way? --------------------------------------------------------------------------- by stof at 2012-02-12T15:13:21Z Well, I generally resolve the conflicts myself instead of asking git to use one version, as generally the final code is not one of the versions by a mix of both versions (as both sides are likely to have done useful changes) --------------------------------------------------------------------------- by Tobion at 2012-02-12T15:15:02Z Yes but the conflicts are in files I never touched and that are not part of my changes. I cannot resolve hundreds of files by hand. --------------------------------------------------------------------------- by Tobion at 2012-02-12T15:41:31Z Finally it worked. I used git reset head~1 and then discarded all foreign changes. There you go. --------------------------------------------------------------------------- by Tobion at 2012-02-14T14:06:04Z @fabpot ping --------------------------------------------------------------------------- by Tobion at 2012-02-20T18:20:50Z @fabpot ping --------------------------------------------------------------------------- by stof at 2012-03-02T22:14:49Z @Tobion the branch needs to be rebased. It conflicts with master --------------------------------------------------------------------------- by Tobion at 2012-03-21T04:22:10Z All done. I don't want to squash commits because they are self-contained fixes and changes that might be needed for future references (like the dynamic tests for -`>run()`).
This commit is contained in:
commit
ee9c986790
@ -31,6 +31,7 @@ class AssetsInstallCommand extends ContainerAwareCommand
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('assets:install')
|
||||
->setDefinition(array(
|
||||
new InputArgument('target', InputArgument::REQUIRED, 'The target directory (usually "web")'),
|
||||
))
|
||||
@ -38,10 +39,10 @@ class AssetsInstallCommand extends ContainerAwareCommand
|
||||
->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks')
|
||||
->setDescription('Installs bundles web assets under a public web directory')
|
||||
->setHelp(<<<EOT
|
||||
The <info>assets:install</info> command installs bundle assets into a given
|
||||
The <info>%command.name%</info> command installs bundle assets into a given
|
||||
directory (e.g. the web directory).
|
||||
|
||||
<info>php app/console assets:install web</info>
|
||||
<info>php %command.full_name% web</info>
|
||||
|
||||
A "bundles" directory will be created inside the target directory, and the
|
||||
"Resources/public" directory of each bundle will be copied into it.
|
||||
@ -49,15 +50,14 @@ A "bundles" directory will be created inside the target directory, and the
|
||||
To create a symlink to each bundle instead of copying its assets, use the
|
||||
<info>--symlink</info> option:
|
||||
|
||||
<info>php app/console assets:install web --symlink</info>
|
||||
<info>php %command.full_name% web --symlink</info>
|
||||
|
||||
To make symlink relative, add the <info>--relative</info> option:
|
||||
|
||||
<info>php app/console assets:install web --symlink --relative</info>
|
||||
<info>php %command.full_name% web --symlink --relative</info>
|
||||
|
||||
EOT
|
||||
)
|
||||
->setName('assets:install')
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,11 @@ class CacheClearCommand extends ContainerAwareCommand
|
||||
))
|
||||
->setDescription('Clears the cache')
|
||||
->setHelp(<<<EOF
|
||||
The <info>cache:clear</info> command clears the application cache for a given environment
|
||||
The <info>%command.name%</info> command clears the application cache for a given environment
|
||||
and debug mode:
|
||||
|
||||
<info>php app/console cache:clear --env=dev</info>
|
||||
<info>php app/console cache:clear --env=prod --no-debug</info>
|
||||
<info>php %command.full_name% --env=dev</info>
|
||||
<info>php %command.full_name% --env=prod --no-debug</info>
|
||||
EOF
|
||||
)
|
||||
;
|
||||
|
@ -34,7 +34,7 @@ class CacheWarmupCommand extends ContainerAwareCommand
|
||||
))
|
||||
->setDescription('Warms up an empty cache')
|
||||
->setHelp(<<<EOF
|
||||
The <info>cache:warmup</info> command warms up the cache.
|
||||
The <info>%command.name%</info> command warms up the cache.
|
||||
|
||||
Before running this command, the cache must be empty.
|
||||
EOF
|
||||
|
@ -33,24 +33,23 @@ class ConfigDumpReferenceCommand extends ContainerDebugCommand
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('config:dump-reference')
|
||||
->setDefinition(array(
|
||||
new InputArgument('name', InputArgument::REQUIRED, 'The Bundle or extension alias')
|
||||
))
|
||||
->setName('config:dump-reference')
|
||||
->setDescription('Dumps default configuration for an extension.')
|
||||
->setDescription('Dumps default configuration for an extension')
|
||||
->setHelp(<<<EOF
|
||||
The <info>config:dump-reference</info> command dumps the default configuration for an extension/bundle.
|
||||
The <info>%command.name%</info> command dumps the default configuration for an extension/bundle.
|
||||
|
||||
The extension alias or bundle name can be used:
|
||||
|
||||
Example:
|
||||
|
||||
<info>%command.name% framework</info>
|
||||
<info>php %command.full_name% framework</info>
|
||||
|
||||
or
|
||||
|
||||
<info>%command.name% FrameworkBundle</info>
|
||||
|
||||
<info>php %command.full_name% FrameworkBundle</info>
|
||||
EOF
|
||||
)
|
||||
;
|
||||
|
@ -40,25 +40,25 @@ class ContainerDebugCommand extends ContainerAwareCommand
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('container:debug')
|
||||
->setDefinition(array(
|
||||
new InputArgument('name', InputArgument::OPTIONAL, 'A service name (foo)'),
|
||||
new InputOption('show-private', null, InputOption::VALUE_NONE, 'Use to show public *and* private services'),
|
||||
))
|
||||
->setName('container:debug')
|
||||
->setDescription('Displays current services for an application')
|
||||
->setHelp(<<<EOF
|
||||
The <info>container:debug</info> command displays all configured <comment>public</comment> services:
|
||||
The <info>%command.name%</info> command displays all configured <comment>public</comment> services:
|
||||
|
||||
<info>container:debug</info>
|
||||
<info>php %command.full_name%</info>
|
||||
|
||||
To get specific information about a service, specify its name:
|
||||
|
||||
<info>container:debug validator</info>
|
||||
<info>php %command.full_name% validator</info>
|
||||
|
||||
By default, private services are hidden. You can display all services by
|
||||
using the --show-private flag:
|
||||
|
||||
<info>container:debug --show-private</info>
|
||||
<info>php %command.full_name% --show-private</info>
|
||||
EOF
|
||||
)
|
||||
;
|
||||
|
@ -47,18 +47,18 @@ class RouterApacheDumperCommand extends ContainerAwareCommand
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('router:dump-apache')
|
||||
->setDefinition(array(
|
||||
new InputArgument('script_name', InputArgument::OPTIONAL, 'The script name of the application\'s front controller.'),
|
||||
new InputOption('base-uri', null, InputOption::VALUE_REQUIRED, 'The base URI'),
|
||||
))
|
||||
->setName('router:dump-apache')
|
||||
->setDescription('Dumps all routes as Apache rewrite rules')
|
||||
->setHelp(<<<EOF
|
||||
The <info>router:dump-apache</info> dumps all routes as Apache rewrite rules.
|
||||
The <info>%command.name%</info> dumps all routes as Apache rewrite rules.
|
||||
These can then be used with the ApacheUrlMatcher to use Apache for route
|
||||
matching.
|
||||
|
||||
<info>router:dump-apache</info>
|
||||
<info>php %command.full_name%</info>
|
||||
EOF
|
||||
)
|
||||
;
|
||||
|
@ -46,15 +46,15 @@ class RouterDebugCommand extends ContainerAwareCommand
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('router:debug')
|
||||
->setDefinition(array(
|
||||
new InputArgument('name', InputArgument::OPTIONAL, 'A route name'),
|
||||
))
|
||||
->setName('router:debug')
|
||||
->setDescription('Displays current routes for an application')
|
||||
->setHelp(<<<EOF
|
||||
The <info>router:debug</info> displays the configured routes:
|
||||
The <info>%command.name%</info> displays the configured routes:
|
||||
|
||||
<info>router:debug</info>
|
||||
<info>php %command.full_name%</info>
|
||||
EOF
|
||||
)
|
||||
;
|
||||
|
@ -46,15 +46,15 @@ class RouterMatchCommand extends ContainerAwareCommand
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('router:match')
|
||||
->setDefinition(array(
|
||||
new InputArgument('path_info', InputArgument::REQUIRED, 'A path info'),
|
||||
))
|
||||
->setName('router:match')
|
||||
->setDescription('Helps debug routes by simulating a path info match')
|
||||
->setHelp(<<<EOF
|
||||
The <info>router:match</info> simulates a path info match:
|
||||
The <info>%command.name%</info> simulates a path info match:
|
||||
|
||||
<info>router:match /foo</info>
|
||||
<info>php %command.full_name% /foo</info>
|
||||
EOF
|
||||
)
|
||||
;
|
||||
|
@ -40,7 +40,6 @@ class TranslationUpdateCommand extends ContainerAwareCommand
|
||||
{
|
||||
$this
|
||||
->setName('translation:update')
|
||||
->setDescription('Update the translation file')
|
||||
->setDefinition(array(
|
||||
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
|
||||
new InputArgument('bundle', InputArgument::REQUIRED, 'The bundle where to load the messages'),
|
||||
@ -61,16 +60,18 @@ class TranslationUpdateCommand extends ContainerAwareCommand
|
||||
'Should the update be done'
|
||||
)
|
||||
))
|
||||
->setDescription('Update the translation file')
|
||||
->setHelp(<<<EOF
|
||||
The <info>translation:update</info> command extract translation strings from templates
|
||||
The <info>%command.name%</info> command extract translation strings from templates
|
||||
of a given bundle. It can display them or merge the new ones into the translation files.
|
||||
When new translation strings are found it can automatically add a prefix to the translation
|
||||
message.
|
||||
|
||||
<info>php app/console translation:update --dump-messages en AcmeBundle</info>
|
||||
<info>php app/console translation:update --force --prefix="new_" fr AcmeBundle</info>
|
||||
<info>php %command.full_name% --dump-messages en AcmeBundle</info>
|
||||
<info>php %command.full_name% --force --prefix="new_" fr AcmeBundle</info>
|
||||
EOF
|
||||
);
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,18 +32,19 @@ class InitAclCommand extends ContainerAwareCommand
|
||||
$this
|
||||
->setName('init:acl')
|
||||
->setDescription('Mounts ACL tables in the database')
|
||||
->setHelp(<<<EOT
|
||||
The <info>init:acl</info> command mounts ACL tables in the database.
|
||||
->setHelp(<<<EOF
|
||||
The <info>%command.name%</info> command mounts ACL tables in the database.
|
||||
|
||||
<info>php app/console init:acl</info>
|
||||
<info>php %command.full_name%</info>
|
||||
|
||||
The name of the DBAL connection must be configured in your <info>app/config/security.yml</info> configuration file in the <info>security.acl.connection</info> variable.
|
||||
|
||||
<info>security:
|
||||
acl:
|
||||
connection: default</info>
|
||||
EOT
|
||||
);
|
||||
EOF
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -560,7 +560,7 @@ class Command
|
||||
|
||||
if ($help = $this->getProcessedHelp()) {
|
||||
$messages[] = '<comment>Help:</comment>';
|
||||
$messages[] = ' '.implode("\n ", explode("\n", $help))."\n";
|
||||
$messages[] = ' '.str_replace("\n", "\n ", $help)."\n";
|
||||
}
|
||||
|
||||
return implode("\n", $messages);
|
||||
@ -585,11 +585,10 @@ class Command
|
||||
$usageXML->appendChild($dom->createTextNode(sprintf($this->getSynopsis(), '')));
|
||||
|
||||
$commandXML->appendChild($descriptionXML = $dom->createElement('description'));
|
||||
$descriptionXML->appendChild($dom->createTextNode(implode("\n ", explode("\n", $this->getDescription()))));
|
||||
$descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $this->getDescription())));
|
||||
|
||||
$commandXML->appendChild($helpXML = $dom->createElement('help'));
|
||||
$help = $this->help;
|
||||
$helpXML->appendChild($dom->createTextNode(implode("\n ", explode("\n", $help))));
|
||||
$helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $this->getProcessedHelp())));
|
||||
|
||||
$commandXML->appendChild($aliasesXML = $dom->createElement('aliases'));
|
||||
foreach ($this->getAliases() as $alias) {
|
||||
|
@ -35,22 +35,23 @@ class HelpCommand extends Command
|
||||
$this->ignoreValidationErrors();
|
||||
|
||||
$this
|
||||
->setName('help')
|
||||
->setDefinition(array(
|
||||
new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
|
||||
new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
|
||||
))
|
||||
->setName('help')
|
||||
->setDescription('Displays help for a command')
|
||||
->setHelp(<<<EOF
|
||||
The <info>help</info> command displays help for a given command:
|
||||
The <info>%command.name%</info> command displays help for a given command:
|
||||
|
||||
<info>php app/console help list</info>
|
||||
<info>php %command.full_name% list</info>
|
||||
|
||||
You can also output the help as XML by using the <comment>--xml</comment> option:
|
||||
|
||||
<info>php app/console help --xml list</info>
|
||||
<info>php %command.full_name% --xml list</info>
|
||||
EOF
|
||||
);
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,27 +32,28 @@ class ListCommand extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setDefinition($this->createDefinition())
|
||||
->setName('list')
|
||||
->setDefinition($this->createDefinition())
|
||||
->setDescription('Lists commands')
|
||||
->setHelp(<<<EOF
|
||||
The <info>list</info> command lists all commands:
|
||||
The <info>%command.name%</info> command lists all commands:
|
||||
|
||||
<info>php app/console list</info>
|
||||
<info>php %command.full_name%</info>
|
||||
|
||||
You can also display the commands for a specific namespace:
|
||||
|
||||
<info>php app/console list test</info>
|
||||
<info>php %command.full_name% test</info>
|
||||
|
||||
You can also output the information as XML by using the <comment>--xml</comment> option:
|
||||
|
||||
<info>php app/console list --xml</info>
|
||||
<info>php %command.full_name% --xml</info>
|
||||
|
||||
It's also possible to get raw list of commands (useful for embedding command runner):
|
||||
|
||||
<info>php app/console list --raw</info>
|
||||
<info>php %command.full_name% --raw</info>
|
||||
EOF
|
||||
);
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,12 +43,8 @@ abstract class Output implements OutputInterface
|
||||
*/
|
||||
public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
|
||||
{
|
||||
if (null === $formatter) {
|
||||
$formatter = new OutputFormatter();
|
||||
}
|
||||
|
||||
$this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
|
||||
$this->formatter = $formatter;
|
||||
$this->formatter = null === $formatter ? new OutputFormatter() : $formatter;
|
||||
$this->formatter->setDecorated((Boolean) $decorated);
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,8 @@ namespace Symfony\Component\Console\Tester;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
/**
|
||||
|
@ -12,12 +12,12 @@
|
||||
namespace Symfony\Tests\Component\Console;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Tester\ApplicationTester;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Tester\ApplicationTester;
|
||||
|
||||
class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -32,11 +32,23 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
require_once self::$fixturesPath.'/Foo3Command.php';
|
||||
}
|
||||
|
||||
protected function normalize($text)
|
||||
protected function normalizeLineBreaks($text)
|
||||
{
|
||||
return str_replace(PHP_EOL, "\n", $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the dynamic placeholders of the command help text with a static version.
|
||||
* The placeholder %command.full_name% includes the script path that is not predictable
|
||||
* and can not be tested against.
|
||||
*/
|
||||
protected function ensureStaticCommandHelp(Application $application)
|
||||
{
|
||||
foreach ($application->all() as $command) {
|
||||
$command->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command->getHelp()));
|
||||
}
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$application = new Application('foo', 'bar');
|
||||
@ -68,7 +80,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
public function testHelp()
|
||||
{
|
||||
$application = new Application();
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_gethelp.txt', str_replace(PHP_EOL, "\n", $application->getHelp()), '->setHelp() returns a help message');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_gethelp.txt', $this->normalizeLineBreaks($application->getHelp()), '->setHelp() returns a help message');
|
||||
}
|
||||
|
||||
public function testAll()
|
||||
@ -279,7 +291,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$application->setCatchExceptions(true);
|
||||
$tester->run(array('command' => 'foo'), array('decorated' => false));
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $this->normalize($tester->getDisplay()), '->setCatchExceptions() sets the catch exception flag');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->setCatchExceptions() sets the catch exception flag');
|
||||
|
||||
$application->setCatchExceptions(false);
|
||||
try {
|
||||
@ -295,14 +307,16 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$application = new Application();
|
||||
$application->add(new \FooCommand);
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext1.txt', str_replace(PHP_EOL, "\n", $application->asText()), '->asText() returns a text representation of the application');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext2.txt', str_replace(PHP_EOL, "\n", $application->asText('foo')), '->asText() returns a text representation of the application');
|
||||
$this->ensureStaticCommandHelp($application);
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext1.txt', $this->normalizeLineBreaks($application->asText()), '->asText() returns a text representation of the application');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext2.txt', $this->normalizeLineBreaks($application->asText('foo')), '->asText() returns a text representation of the application');
|
||||
}
|
||||
|
||||
public function testAsXml()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->add(new \FooCommand);
|
||||
$this->ensureStaticCommandHelp($application);
|
||||
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml1.txt', $application->asXml(), '->asXml() returns an XML representation of the application');
|
||||
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml2.txt', $application->asXml('foo'), '->asXml() returns an XML representation of the application');
|
||||
}
|
||||
@ -314,18 +328,18 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
$tester = new ApplicationTester($application);
|
||||
|
||||
$tester->run(array('command' => 'foo'), array('decorated' => false));
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $this->normalize($tester->getDisplay()), '->renderException() renders a pretty exception');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->renderException() renders a pretty exception');
|
||||
|
||||
$tester->run(array('command' => 'foo'), array('decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE));
|
||||
$this->assertRegExp('/Exception trace/', $this->normalize($tester->getDisplay()), '->renderException() renders a pretty exception with a stack trace when verbosity is verbose');
|
||||
$this->assertContains('Exception trace', $tester->getDisplay(), '->renderException() renders a pretty exception with a stack trace when verbosity is verbose');
|
||||
|
||||
$tester->run(array('command' => 'list', '--foo' => true), array('decorated' => false));
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception2.txt', $this->normalize($tester->getDisplay()), '->renderException() renders the command synopsis when an exception occurs in the context of a command');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception2.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->renderException() renders the command synopsis when an exception occurs in the context of a command');
|
||||
|
||||
$application->add(new \Foo3Command);
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'foo3:bar'), array('decorated' => false));
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt', $this->normalize($tester->getDisplay()), '->renderException() renders a pretty exceptions with previous exceptions');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->renderException() renders a pretty exceptions with previous exceptions');
|
||||
|
||||
}
|
||||
|
||||
@ -341,82 +355,66 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
$application->run();
|
||||
ob_end_clean();
|
||||
|
||||
$this->assertEquals('Symfony\Component\Console\Input\ArgvInput', get_class($command->input), '->run() creates an ArgvInput by default if none is given');
|
||||
$this->assertEquals('Symfony\Component\Console\Output\ConsoleOutput', get_class($command->output), '->run() creates a ConsoleOutput by default if none is given');
|
||||
$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');
|
||||
|
||||
$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', $this->normalize($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->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $this->normalize($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->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $this->normalize($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');
|
||||
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->setCatchExceptions(false);
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'list', '--help' => true), array('decorated' => false));
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $this->normalize($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->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $this->normalize($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');
|
||||
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->setCatchExceptions(false);
|
||||
$tester = new ApplicationTester($application);
|
||||
$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');
|
||||
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->setCatchExceptions(false);
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('--version' => true), array('decorated' => false));
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $this->normalize($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->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $this->normalize($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');
|
||||
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->setCatchExceptions(false);
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'list', '--quiet' => true));
|
||||
$this->assertEquals('', $this->normalize($tester->getDisplay()), '->run() removes all output if --quiet is passed');
|
||||
$this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed');
|
||||
|
||||
$tester->run(array('command' => 'list', '-q' => true));
|
||||
$this->assertEquals('', $this->normalize($tester->getDisplay()), '->run() removes all output if -q is passed');
|
||||
$this->assertSame('', $tester->getDisplay(), '->run() removes all output if -q is passed');
|
||||
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->setCatchExceptions(false);
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'list', '--verbose' => true));
|
||||
$this->assertEquals(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose is --verbose is passed');
|
||||
$this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose is passed');
|
||||
|
||||
$tester->run(array('command' => 'list', '-v' => true));
|
||||
$this->assertEquals(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose is -v is passed');
|
||||
$this->assertSame(Output::VERBOSITY_VERBOSE, $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->assertEquals("called\n", $this->normalize($tester->getDisplay()), '->run() does not called interact() if --no-interaction is passed');
|
||||
$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->assertEquals("called\n", $this->normalize($tester->getDisplay()), '->run() does not called interact() if -n is passed');
|
||||
$this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,6 +128,14 @@ class CommandTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help');
|
||||
}
|
||||
|
||||
public function testGetProcessedHelp()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->setHelp('The %command.name% command does... Example: php %command.full_name%.');
|
||||
$this->assertContains('The namespace:name command does...', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.name% correctly');
|
||||
$this->assertNotContains('%command.full_name%', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.full_name%');
|
||||
}
|
||||
|
||||
public function testGetSetAliases()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
|
Reference in New Issue
Block a user