merged branch xanido/fix-list-command (PR #8115)

This PR was merged into the 2.3 branch.

Discussion
----------

[Console] Add namespace support back in to list command

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | Couldn't spot this issue in the list
| License       | MIT
| Doc PR        | NA

Added a test to prevent this happening again.

Commits
-------

79a842a [Console] Add namespace support back in to list command
This commit is contained in:
Fabien Potencier 2013-05-25 18:58:35 +02:00
commit fb7adaa417
3 changed files with 19 additions and 3 deletions

View File

@ -73,7 +73,7 @@ EOF
}
$helper = new DescriptorHelper();
$helper->describe($output, $this->getApplication(), $input->getOption('format'), $input->getOption('raw'));
$helper->describe($output, $this->getApplication(), $input->getOption('format'), $input->getOption('raw'), $input->getArgument('namespace'));
}
/**

View File

@ -56,9 +56,9 @@ class DescriptorHelper extends Helper
* @param string $format
* @param boolean $raw
*/
public function describe(OutputInterface $output, $object, $format = null, $raw = false)
public function describe(OutputInterface $output, $object, $format = null, $raw = false, $namespace = null)
{
$options = array('raw_text' => $raw, 'format' => $format ?: 'txt');
$options = array('raw_text' => $raw, 'format' => $format ?: 'txt', 'namespace' => $namespace);
$type = !$raw && 'txt' === $options['format'] ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW;
if (!isset($this->descriptors[$options['format']])) {

View File

@ -42,6 +42,22 @@ class ListCommandTest extends \PHPUnit_Framework_TestCase
help Displays help for a command
list Lists commands
EOF;
$this->assertEquals($output, $commandTester->getDisplay(true));
}
public function testExecuteListsCommandsWithNamespaceArgument()
{
require_once(realpath(__DIR__.'/../Fixtures/FooCommand.php'));
$application = new Application();
$application->add(new \FooCommand());
$commandTester = new CommandTester($command = $application->get('list'));
$commandTester->execute(array('command' => $command->getName(), 'namespace' => 'foo', '--raw' => true));
$output = <<<EOF
foo:bar The foo:bar command
EOF;
$this->assertEquals($output, $commandTester->getDisplay(true));