diff --git a/cake/console/libs/help_formatter.php b/cake/console/libs/help_formatter.php index 107fa2fa3..7af4cadf1 100644 --- a/cake/console/libs/help_formatter.php +++ b/cake/console/libs/help_formatter.php @@ -152,7 +152,7 @@ class HelpFormatter { * @param boolean $string Return the SimpleXml object or a string. Defaults to true. * @return mixed. See $string */ - public function xml($string = false) { + public function xml($string = true) { $parser = $this->_parser; $xml = new SimpleXmlElement(''); $xml->addChild('commmand', $parser->command()); @@ -171,6 +171,6 @@ class HelpFormatter { foreach ($parser->arguments() as $argument) { $argument->xml($arguments); } - return $xml->asXml(); + return $string ? $xml->asXml() : $xml; } } \ No newline at end of file diff --git a/cake/tests/cases/console/libs/help_formatter.test.php b/cake/tests/cases/console/libs/help_formatter.test.php index 3df204133..a957843b1 100644 --- a/cake/tests/cases/console/libs/help_formatter.test.php +++ b/cake/tests/cases/console/libs/help_formatter.test.php @@ -421,4 +421,20 @@ TEXT; TEXT; $this->assertEquals(new DomDocument($expected), new DomDocument($result), 'Help does not match'); } + +/** + * Test xml help as object + * + * @return void + */ + function testXmlHelpAsObject() { + $parser = new ConsoleOptionParser('mycommand', false); + $parser->addOption('test', array('help' => 'A test option.')) + ->addArgument('model', array('help' => 'The model to make.', 'required' => true)) + ->addArgument('other_longer', array('help' => 'Another argument.')); + + $formatter = new HelpFormatter($parser); + $result = $formatter->xml(false); + $this->assertType('SimpleXmlElement', $result); + } }