浏览代码

[Console] Fixed invalid help command shortcut

Fabien Pennequin 15 年之前
父节点
当前提交
56935f85df

+ 1 - 1
src/Symfony/Component/Console/Application.php

@@ -147,7 +147,7 @@ class Application
             $output->setDecorated(true);
         }
 
-        if (true === $input->hasParameterOption(array('--help', '-H'))) {
+        if (true === $input->hasParameterOption(array('--help', '-h'))) {
             if (!$name) {
                 $name = 'help';
                 $input = new ArrayInput(array('command' => 'help'));

+ 6 - 0
tests/Symfony/Tests/Component/Console/ApplicationTest.php

@@ -267,6 +267,9 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
         $tester->run(array('--help' => true));
         $this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(), '->run() runs the help command if --help is passed');
 
+        $tester->run(array('-h' => true));
+        $this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(), '->run() runs the help command if -h is passed');
+
         $application = new Application();
         $application->setAutoExit(false);
         $application->setCatchExceptions(false);
@@ -274,6 +277,9 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
         $tester->run(array('command' => 'list', '--help' => true));
         $this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(), '->run() displays the help if --help is passed');
 
+        $tester->run(array('command' => 'list', '-h' => true));
+        $this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(), '->run() displays the help if -h is passed');
+
         $application = new Application();
         $application->setAutoExit(false);
         $application->setCatchExceptions(false);