From 79a842a83d140d024f49b06cc61f9598f22e93a9 Mon Sep 17 00:00:00 2001 From: Tim Anido Date: Wed, 22 May 2013 12:45:49 +1000 Subject: [PATCH] [Console] Add namespace support back in to list command --- .../Component/Console/Command/ListCommand.php | 2 +- .../Console/Helper/DescriptorHelper.php | 4 ++-- .../Console/Tests/Command/ListCommandTest.php | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Command/ListCommand.php b/src/Symfony/Component/Console/Command/ListCommand.php index bc047a87fd..f3d7438d09 100644 --- a/src/Symfony/Component/Console/Command/ListCommand.php +++ b/src/Symfony/Component/Console/Command/ListCommand.php @@ -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')); } /** diff --git a/src/Symfony/Component/Console/Helper/DescriptorHelper.php b/src/Symfony/Component/Console/Helper/DescriptorHelper.php index a114096562..b897a33fec 100644 --- a/src/Symfony/Component/Console/Helper/DescriptorHelper.php +++ b/src/Symfony/Component/Console/Helper/DescriptorHelper.php @@ -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']])) { diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index aa780fee77..1df06f5d94 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -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 = <<assertEquals($output, $commandTester->getDisplay(true));