convertDomElementToArray should handle zero values

This commit is contained in:
Ben Davies 2014-03-11 17:36:00 +00:00 committed by Fabien Potencier
parent e8dadd5398
commit 34720c921e
2 changed files with 2 additions and 1 deletions

View File

@ -80,6 +80,7 @@ class XmlUtilsTest extends \PHPUnit_Framework_TestCase
array(array('foo' => null), '<foo />'),
array(array('foo' => 'bar'), '<foo>bar</foo>'),
array(array('foo' => array('foo' => 'bar')), '<foo foo="bar"/>'),
array(array('foo' => array('foo' => 0)), '<foo><foo>0</foo></foo>'),
array(array('foo' => array('foo' => 'bar')), '<foo><foo>bar</foo></foo>'),
array(array('foo' => array('foo' => 'bar', 'value' => 'text')), '<foo foo="bar">text</foo>'),
array(array('foo' => array('attr' => 'bar', 'foo' => 'text')), '<foo attr="bar"><foo>text</foo></foo>'),

View File

@ -132,7 +132,7 @@ class XmlUtils
$nodeValue = false;
foreach ($element->childNodes as $node) {
if ($node instanceof \DOMText) {
if (trim($node->nodeValue)) {
if (strlen(trim($node->nodeValue)) > 0) {
$nodeValue = trim($node->nodeValue);
$empty = false;
}