10000 [Console] do not make the getHelp() method smart by xabbuh · Pull Request #15976 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] do not make the getHelp() method smart #15976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ public function setHelp($help)
*/
public function getHelp()
{
return $this->help ?: $this->description;
return $this->help;
}

/**
Expand All @@ -513,7 +513,7 @@ public function getProcessedHelp()
$_SERVER['PHP_SELF'].' '.$name,
);

return str_replace($placeholders, $replacements, $this->getHelp());
return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Component/Console/Tests/Command/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function testGetSetHelp()
$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()
Expand All @@ -141,6 +141,10 @@ public function testGetProcessedHelp()
$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()
Expand Down
0