Skip to content

Commit 3c44ddd

Browse files
committed
Add tests for #9870
1 parent 4d77cb0 commit 3c44ddd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/Cake/Test/Case/Utility/XmlTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,15 @@ public function testFromArray() {
395395
$obj = Xml::fromArray($xml, 'attributes');
396396
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?><tags><tag id="1">defect</tag></tags>';
397397
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
398+
}
398399

400+
/**
401+
* Test fromArray() with zero values.
402+
*
403+
* @return void
404+
*/
405+
public function testFromArrayZeroValue()
406+
{
399407
$xml = array(
400408
'tag' => array(
401409
'@' => 0,
@@ -406,6 +414,16 @@ public function testFromArray() {
406414
$xmlText = <<<XML
407415
<?xml version="1.0" encoding="UTF-8"?>
408416
<tag test="A test">0</tag>
417+
XML;
418+
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
419+
420+
$xml = array(
421+
'tag' => array('0')
422+
);
423+
$obj = Xml::fromArray($xml);
424+
$xmlText = <<<XML
425+
<?xml version="1.0" encoding="UTF-8"?>
426+
<tag>0</tag>
409427
XML;
410428
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
411429
}

0 commit comments

Comments
 (0)