Skip to content

Commit

Permalink
change formatOutput option name to pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
ceeram committed Mar 13, 2013
1 parent 2f79894 commit f6477d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions lib/Cake/Test/Case/Utility/XmlTest.php
Expand Up @@ -403,11 +403,11 @@ public function testFromArrayNonSequentialKeys() {
}

/**
* testFromArrayFormatOutput method
* testFromArrayPretty method
*
* @return void
*/
public function testFromArrayFormatOutput() {
public function testFromArrayPretty() {
$xml = array(
'tags' => array(
'tag' => array(
Expand All @@ -428,7 +428,7 @@ public function testFromArrayFormatOutput() {
<tags><tag><id>1</id><name>defect</name></tag><tag><id>2</id><name>enhancement</name></tag></tags>
XML;
$xmlResponse = Xml::fromArray($xml, array('formatOutput' => false));
$xmlResponse = Xml::fromArray($xml, array('pretty' => false));
$this->assertEquals($expected, $xmlResponse->asXML());

$expected = <<<XML
Expand All @@ -445,7 +445,7 @@ public function testFromArrayFormatOutput() {
</tags>
XML;
$xmlResponse = Xml::fromArray($xml, array('formatOutput' => true));
$xmlResponse = Xml::fromArray($xml, array('pretty' => true));
$this->assertEquals($expected, $xmlResponse->asXML());

$xml = array(
Expand All @@ -468,7 +468,7 @@ public function testFromArrayFormatOutput() {
<tags><tag id="1" name="defect"/><tag id="2" name="enhancement"/></tags>
XML;
$xmlResponse = Xml::fromArray($xml, array('formatOutput' => false, 'format' => 'attributes'));
$xmlResponse = Xml::fromArray($xml, array('pretty' => false, 'format' => 'attributes'));
$this->assertEquals($expected, $xmlResponse->asXML());

$expected = <<<XML
Expand All @@ -479,7 +479,7 @@ public function testFromArrayFormatOutput() {
</tags>
XML;
$xmlResponse = Xml::fromArray($xml, array('formatOutput' => true, 'format' => 'attributes'));
$xmlResponse = Xml::fromArray($xml, array('pretty' => true, 'format' => 'attributes'));
$this->assertEquals($expected, $xmlResponse->asXML());
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Utility/Xml.php
Expand Up @@ -150,7 +150,7 @@ protected static function _loadXml($input, $options) {
* ### Options
*
* - `format` If create childs ('tags') or attributes ('attribute').
* - `formatOutput` Returns formatted Xml when set to `true`. Defaults to `false`
* - `pretty` Returns formatted Xml when set to `true`. Defaults to `false`
* - `version` Version of XML document. Default is 1.0.
* - `encoding` Encoding of XML document. If null remove from XML header. Default is the some of application.
* - `return` If return object of SimpleXMLElement ('simplexml') or DOMDocument ('domdocument'). Default is SimpleXMLElement.
Expand Down Expand Up @@ -199,12 +199,12 @@ public static function fromArray($input, $options = array()) {
'version' => '1.0',
'encoding' => Configure::read('App.encoding'),
'return' => 'simplexml',
'formatOutput' => false
'pretty' => false
);
$options = array_merge($defaults, $options);

$dom = new DOMDocument($options['version'], $options['encoding']);
if ($options['formatOutput']) {
if ($options['pretty']) {
$dom->formatOutput = true;
}
self::_fromArray($dom, $dom, $input, $options['format']);
Expand Down

0 comments on commit f6477d5

Please sign in to comment.