mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-12 20:49:50 +00:00
Fixing _name_ elements being inserted into serialized xml from Xml lib. Test case added. Fixes #367
This commit is contained in:
parent
ad20e43730
commit
26aa3731e0
2 changed files with 24 additions and 7 deletions
|
@ -241,7 +241,7 @@ class XmlNode extends Object {
|
|||
}
|
||||
|
||||
$n = $name;
|
||||
if (!empty($chldObjs['_name_'])) {
|
||||
if (isset($chldObjs['_name_'])) {
|
||||
$n = null;
|
||||
unset($chldObjs['_name_']);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,6 @@ class XmlTest extends CakeTestCase {
|
|||
$result =& new Xml($data, array('format' => 'tags'));
|
||||
$expected = '<statuses><status><id>1</id></status><status><id>2</id></status></statuses>';
|
||||
$this->assertIdentical($result->toString(), $expected);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -258,7 +257,7 @@ class XmlTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testArraySerialization() {
|
||||
function testSerializationArray() {
|
||||
$input = array(
|
||||
array(
|
||||
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
|
||||
|
@ -285,7 +284,7 @@ class XmlTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testNestedArraySerialization() {
|
||||
function testSerializationNestedArray() {
|
||||
$input = array(
|
||||
array(
|
||||
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
|
||||
|
@ -330,9 +329,9 @@ class XmlTest extends CakeTestCase {
|
|||
*/
|
||||
function testArraySerializationWithRoot() {
|
||||
$input = array(
|
||||
array('Shirt' => array('id' => 1, 'color' => 'green')),
|
||||
array('Shirt' => array('id' => 2, 'color' => 'blue')),
|
||||
);
|
||||
array('Shirt' => array('id' => 1, 'color' => 'green')),
|
||||
array('Shirt' => array('id' => 2, 'color' => 'blue')),
|
||||
);
|
||||
$expected = '<collection><shirt id="1" color="green" />';
|
||||
$expected .= '<shirt id="2" color="blue" /></collection>';
|
||||
|
||||
|
@ -699,6 +698,24 @@ class XmlTest extends CakeTestCase {
|
|||
$result = $xml->toString(array('header' => false, 'cdata' => false));
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
/**
|
||||
* ensure that normalize does not add _name_ elements that come from Set::map sometimes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testNormalizeNotAdding_name_Element() {
|
||||
$input = array(
|
||||
'output' => array(
|
||||
'Vouchers' => array(
|
||||
array('Voucher' => array('id' => 1)),
|
||||
array('Voucher' => array('id' => 2)),
|
||||
),
|
||||
)
|
||||
);
|
||||
$xml = new Xml($input, array('attributes' => false, 'format' => 'tags'));
|
||||
$this->assertFalse(isset($xml->children[0]->children[0]->children[1]), 'Too many children %s');
|
||||
$this->assertEqual($xml->children[0]->children[0]->children[0]->name, 'voucher');
|
||||
}
|
||||
/**
|
||||
* testSimpleParsing method
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue