mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing bug when value is '0', it was generating a blank node.
This commit is contained in:
parent
20ef932156
commit
317049b736
2 changed files with 17 additions and 4 deletions
|
@ -227,7 +227,7 @@ class XmlNode extends Object {
|
|||
$chldObjs = get_object_vars($object);
|
||||
} elseif (is_array($object)) {
|
||||
$chldObjs = $object;
|
||||
} elseif (!empty($object) || $object === 0) {
|
||||
} elseif (!empty($object) || $object === 0 || $object === '0') {
|
||||
$node->createTextNode($object);
|
||||
}
|
||||
$attr = array();
|
||||
|
@ -268,7 +268,7 @@ class XmlNode extends Object {
|
|||
$node->normalize($val, $n, $options);
|
||||
} elseif ($options['format'] == 'tags' && $this->__tagOptions($key) !== false) {
|
||||
$tmp =& $node->createElement($key);
|
||||
if (!empty($val) || $val === 0) {
|
||||
if (!empty($val) || $val === 0 || $val === '0') {
|
||||
$tmp->createTextNode($val);
|
||||
}
|
||||
} elseif ($options['format'] == 'attributes') {
|
||||
|
|
|
@ -176,6 +176,19 @@ class XmlTest extends CakeTestCase {
|
|||
$expected = '<hello><![CDATA[world]]></hello>';
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
/**
|
||||
* testSimpleArrayWithZeroValues method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testSimpleArrayWithZeroValues() {
|
||||
$xml = new Xml(array('zero_string' => '0', 'zero_integer' => 0), array('format' => 'tags'));
|
||||
|
||||
$result = $xml->toString(false);
|
||||
$expected = '<zero_string>0</zero_string><zero_integer>0</zero_integer>';
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
/**
|
||||
* testHeader method
|
||||
*
|
||||
|
@ -761,7 +774,7 @@ class XmlTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* test that empty values do not casefold collapse
|
||||
*
|
||||
*
|
||||
* @see http://code.cakephp.org/tickets/view/8
|
||||
* @return void
|
||||
**/
|
||||
|
@ -797,7 +810,7 @@ class XmlTest extends CakeTestCase {
|
|||
<name>varchar(45)</name>
|
||||
</User>
|
||||
</method>';
|
||||
|
||||
|
||||
$xml =& new XML($emptyValue);
|
||||
$expected = array(
|
||||
'Method' => array(
|
||||
|
|
Loading…
Reference in a new issue