Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 0cfdb87cdfe0eccddac1071fb81d651e3de56a90 1 parent e527eab
@aymericderbois aymericderbois authored
View
13 lib/Cake/Test/Case/Utility/XmlTest.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());
}
/**
View
2  lib/Cake/Utility/Xml.php
@@ -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) {
Please sign in to comment.
Something went wrong with that request. Please try again.