Back port fixes from #7899 to 2.x

Fix XmlView failing when return => domdocument is used.
This commit is contained in:
mark_story 2016-01-03 22:08:09 -05:00
parent c6d9911b9c
commit 4de92123fa
2 changed files with 5 additions and 2 deletions

View file

@ -107,7 +107,7 @@ class XmlViewTest extends CakeTestCase {
$Controller = new Controller($Request, $Response);
$data = array(
'_serialize' => array('tags'),
'_xmlOptions' => array('format' => 'attributes'),
'_xmlOptions' => array('format' => 'attributes', 'return' => 'domdocument'),
'tags' => array(
'tag' => array(
array(
@ -126,7 +126,7 @@ class XmlViewTest extends CakeTestCase {
$View = new XmlView($Controller);
$result = $View->render();
$expected = Xml::build(array('response' => array('tags' => $data['tags'])), $data['_xmlOptions'])->asXML();
$expected = Xml::build(array('response' => array('tags' => $data['tags'])), $data['_xmlOptions'])->saveXML();
$this->assertSame($expected, $result);
}

View file

@ -142,6 +142,9 @@ class XmlView extends View {
$options['pretty'] = true;
}
if (isset($options['return']) && strtolower($options['return']) === 'domdocument') {
return Xml::fromArray($data, $options)->saveXML();
}
return Xml::fromArray($data, $options)->asXML();
}