Merge branch 'domingues-2x' into 2.x

Refs #9870
This commit is contained in:
mark_story 2016-12-13 22:48:12 -05:00
commit 99af4bba83
2 changed files with 19 additions and 1 deletions

View file

@ -395,7 +395,15 @@ XML;
$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());
}
/**
* Test fromArray() with zero values.
*
* @return void
*/
public function testFromArrayZeroValue()
{
$xml = array(
'tag' => array(
'@' => 0,
@ -406,6 +414,16 @@ XML;
$xmlText = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<tag test="A test">0</tag>
XML;
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
$xml = array(
'tag' => array('0')
);
$obj = Xml::fromArray($xml);
$xmlText = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<tag>0</tag>
XML;
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
}

View file

@ -312,7 +312,7 @@ class Xml {
$childNS = $value['xmlns:'];
unset($value['xmlns:']);
}
} elseif (!empty($value) || $value === 0) {
} elseif (!empty($value) || $value === 0 || $value === '0') {
$childValue = (string)$value;
}