Skip to content
Permalink
Browse files

Fix a problem of tag values which is not taken into account

(when equal to zero) when passing an array to XML object.
  • Loading branch information...
aymericderbois committed Jun 8, 2013
1 parent e527eab commit 0cfdb87cdfe0eccddac1071fb81d651e3de56a90
Showing with 14 additions and 1 deletion.
  1. +13 −0 lib/Cake/Test/Case/Utility/XmlTest.php
  2. +1 −1 lib/Cake/Utility/Xml.php
@@ -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());
}
/**
@@ -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) {

0 comments on commit 0cfdb87

Please sign in to comment.
You can’t perform that action at this time.