mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding return of xml object to xml() method.
This commit is contained in:
parent
ad62e0e3af
commit
8f9adc7b15
2 changed files with 18 additions and 2 deletions
|
@ -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('<shell></shell>');
|
||||
$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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue