Skip to content

Commit

Permalink
Merge pull request #1338 from aymericderbois/FixErrorWithZeroValueXml
Browse files Browse the repository at this point in the history
Fix bug in Xml::_createChild Method
  • Loading branch information
markstory committed Jun 9, 2013
2 parents e527eab + 0cfdb87 commit 0f38dbd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/Cake/Test/Case/Utility/XmlTest.php
Expand Up @@ -375,6 +375,19 @@ public function testFromArray() {
$obj = Xml::fromArray($xml, 'attributes');
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?><tags><tag id="1">defect</tag></tags>';
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());

$xml = array(
'tag' => array(
'@' => 0,
'@test' => 'A test'
)
);
$obj = Xml::fromArray($xml);
$xmlText = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<tag test="A test">0</tag>
XML;
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/Xml.php
Expand Up @@ -310,7 +310,7 @@ protected static function _createChild($data) {
}

$child = $dom->createElement($key);
if ($childValue) {
if (!is_null($childValue)) {
$child->appendChild($dom->createTextNode($childValue));
}
if ($childNS) {
Expand Down

0 comments on commit 0f38dbd

Please sign in to comment.