From 0cfdb87cdfe0eccddac1071fb81d651e3de56a90 Mon Sep 17 00:00:00 2001 From: Aymeric Derbois Date: Sun, 9 Jun 2013 00:48:59 +0200 Subject: [PATCH] Fix a problem of tag values which is not taken into account (when equal to zero) when passing an array to XML object. --- lib/Cake/Test/Case/Utility/XmlTest.php | 13 +++++++++++++ lib/Cake/Utility/Xml.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php index 46dac3b27..7896ed4c9 100644 --- a/lib/Cake/Test/Case/Utility/XmlTest.php +++ b/lib/Cake/Test/Case/Utility/XmlTest.php @@ -375,6 +375,19 @@ XML; $obj = Xml::fromArray($xml, 'attributes'); $xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?>defect'; $this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML()); + + $xml = array( + 'tag' => array( + '@' => 0, + '@test' => 'A test' + ) + ); + $obj = Xml::fromArray($xml); + $xmlText = << +0 +XML; + $this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML()); } /** diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php index 862f6c1d4..88d4e19a0 100644 --- a/lib/Cake/Utility/Xml.php +++ b/lib/Cake/Utility/Xml.php @@ -310,7 +310,7 @@ class Xml { } $child = $dom->createElement($key); - if ($childValue) { + if (!is_null($childValue)) { $child->appendChild($dom->createTextNode($childValue)); } if ($childNS) {