From fb756c5aee34309f9e1c7caab6323ae7b7ee7e7c Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 6 Aug 2011 09:52:07 -0400 Subject: [PATCH] Fixing incorrectly inflected shell names in help. --- lib/Cake/Console/ConsoleOptionParser.php | 4 ++-- .../Test/Case/Console/ConsoleOptionParserTest.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Console/ConsoleOptionParser.php b/lib/Cake/Console/ConsoleOptionParser.php index 16a78112d..56a44197d 100644 --- a/lib/Cake/Console/ConsoleOptionParser.php +++ b/lib/Cake/Console/ConsoleOptionParser.php @@ -124,7 +124,7 @@ class ConsoleOptionParser { * this to false will prevent the addition of `--verbose` & `--quiet` options. */ public function __construct($command = null, $defaultOptions = true) { - $this->_command = $command; + $this->command($command); $this->addOption('help', array( 'short' => 'h', @@ -206,7 +206,7 @@ class ConsoleOptionParser { */ public function command($text = null) { if ($text !== null) { - $this->_command = $text; + $this->_command = Inflector::underscore($text); return $this; } return $this->_command; diff --git a/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php b/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php index 9d9828ae6..1712b0d35 100644 --- a/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php +++ b/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php @@ -496,6 +496,16 @@ TEXT; $this->assertEquals('factory', $parser->command()); } +/** + * test that command() inflects the command name. + * + * @return void + */ + public function testCommandInflection() { + $parser = new ConsoleOptionParser('CommandLine'); + $this->assertEquals('command_line', $parser->command()); + } + /** * test that parse() takes a subcommand argument, and that the subcommand parser * is used. @@ -529,4 +539,4 @@ TEXT; $this->assertEquals($expected, $result, 'Sub parser did not parse request.'); } -} \ No newline at end of file +}