diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index bccbc2ff4b..3e298b5a62 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -491,7 +491,7 @@ class Command */ public function getHelp() { - return $this->help ?: $this->description; + return $this->help; } /** @@ -513,7 +513,7 @@ class Command $_SERVER['PHP_SELF'].' '.$name, ); - return str_replace($placeholders, $replacements, $this->getHelp()); + return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription()); } /** diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index a252fe7127..baa7c7e3df 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -132,7 +132,7 @@ class CommandTest extends \PHPUnit_Framework_TestCase $this->assertEquals($command, $ret, '->setHelp() implements a fluent interface'); $this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help'); $command->setHelp(''); - $this->assertEquals('description', $command->getHelp(), '->getHelp() fallback to the description'); + $this->assertEquals('', $command->getHelp(), '->getHelp() does not fall back to the description'); } public function testGetProcessedHelp() @@ -141,6 +141,10 @@ class CommandTest extends \PHPUnit_Framework_TestCase $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%'); + + $command = new \TestCommand(); + $command->setHelp(''); + $this->assertContains('description', $command->getProcessedHelp(), '->getProcessedHelp() falls back to the description'); } public function testGetSetAliases()