mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '2.1' into 2.2
Conflicts: lib/Cake/Model/Datasource/DataSource.php lib/Cake/VERSION.txt
This commit is contained in:
commit
7b5e45b965
4 changed files with 231 additions and 72 deletions
|
@ -542,4 +542,23 @@ class ControllerTestCaseTest extends CakeTestCase {
|
||||||
$this->assertSame($this->Case->controller->request, $this->Case->controller->RequestHandler->request);
|
$this->assertSame($this->Case->controller->request, $this->Case->controller->RequestHandler->request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that testAction() doesn't destroy data in GET & POST
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testRestoreGetPost() {
|
||||||
|
$restored = array('new' => 'value');
|
||||||
|
|
||||||
|
$_GET = $restored;
|
||||||
|
$_POST = $restored;
|
||||||
|
|
||||||
|
$this->Case->generate('TestsApps');
|
||||||
|
$options = array('method' => 'get');
|
||||||
|
$this->Case->testAction('/tests_apps/index', $options);
|
||||||
|
|
||||||
|
$this->assertEquals($restored, $_GET);
|
||||||
|
$this->assertEquals($restored, $_POST);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,8 +141,14 @@ class XmlTest extends CakeTestCase {
|
||||||
$obj = Xml::build($xml, array('return' => 'domdocument'));
|
$obj = Xml::build($xml, array('return' => 'domdocument'));
|
||||||
$this->assertEquals('tags', $obj->firstChild->nodeName);
|
$this->assertEquals('tags', $obj->firstChild->nodeName);
|
||||||
|
|
||||||
$this->assertEquals(Xml::build($xml, array('return' => 'domdocument')), Xml::build(file_get_contents($xml), array('return' => 'domdocument')));
|
$this->assertEquals(
|
||||||
$this->assertEquals(Xml::build($xml, array('return' => 'simplexml')), Xml::build($xml, 'simplexml'));
|
Xml::build($xml, array('return' => 'domdocument')),
|
||||||
|
Xml::build(file_get_contents($xml), array('return' => 'domdocument'))
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
Xml::build($xml, array('return' => 'simplexml')),
|
||||||
|
Xml::build($xml, 'simplexml')
|
||||||
|
);
|
||||||
|
|
||||||
$xml = array('tag' => 'value');
|
$xml = array('tag' => 'value');
|
||||||
$obj = Xml::build($xml);
|
$obj = Xml::build($xml);
|
||||||
|
@ -234,15 +240,33 @@ class XmlTest extends CakeTestCase {
|
||||||
$this->assertTrue($obj instanceof SimpleXMLElement);
|
$this->assertTrue($obj instanceof SimpleXMLElement);
|
||||||
$this->assertEquals('tags', $obj->getName());
|
$this->assertEquals('tags', $obj->getName());
|
||||||
$this->assertEquals(2, count($obj));
|
$this->assertEquals(2, count($obj));
|
||||||
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?><tags><tag id="1" name="defect"/><tag id="2" name="enhancement"/></tags>';
|
$xmlText = <<<XML
|
||||||
$this->assertEquals(str_replace(array("\r", "\n"), '', $obj->asXML()), $xmlText);
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<tags>
|
||||||
|
<tag id="1" name="defect"/>
|
||||||
|
<tag id="2" name="enhancement"/>
|
||||||
|
</tags>
|
||||||
|
XML;
|
||||||
|
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
|
||||||
|
|
||||||
$obj = Xml::fromArray($xml);
|
$obj = Xml::fromArray($xml);
|
||||||
$this->assertTrue($obj instanceof SimpleXMLElement);
|
$this->assertTrue($obj instanceof SimpleXMLElement);
|
||||||
$this->assertEquals('tags', $obj->getName());
|
$this->assertEquals('tags', $obj->getName());
|
||||||
$this->assertEquals(2, count($obj));
|
$this->assertEquals(2, count($obj));
|
||||||
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?><tags><tag><id>1</id><name>defect</name></tag><tag><id>2</id><name>enhancement</name></tag></tags>';
|
$xmlText = <<<XML
|
||||||
$this->assertEquals(str_replace(array("\r", "\n"), '', $obj->asXML()), $xmlText);
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<tags>
|
||||||
|
<tag>
|
||||||
|
<id>1</id>
|
||||||
|
<name>defect</name>
|
||||||
|
</tag>
|
||||||
|
<tag>
|
||||||
|
<id>2</id>
|
||||||
|
<name>enhancement</name>
|
||||||
|
</tag>
|
||||||
|
</tags>
|
||||||
|
XML;
|
||||||
|
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
|
||||||
|
|
||||||
$xml = array(
|
$xml = array(
|
||||||
'tags' => array(
|
'tags' => array(
|
||||||
|
@ -286,8 +310,18 @@ class XmlTest extends CakeTestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$obj = Xml::fromArray($xml, 'tags');
|
$obj = Xml::fromArray($xml, 'tags');
|
||||||
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?><tags><tag id="1"><name>defect</name></tag><tag id="2"><name>enhancement</name></tag></tags>';
|
$xmlText = <<<XML
|
||||||
$this->assertEquals(str_replace(array("\r", "\n"), '', $obj->asXML()), $xmlText);
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<tags>
|
||||||
|
<tag id="1">
|
||||||
|
<name>defect</name>
|
||||||
|
</tag>
|
||||||
|
<tag id="2">
|
||||||
|
<name>enhancement</name>
|
||||||
|
</tag>
|
||||||
|
</tags>
|
||||||
|
XML;
|
||||||
|
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
|
||||||
|
|
||||||
$xml = array(
|
$xml = array(
|
||||||
'tags' => array(
|
'tags' => array(
|
||||||
|
@ -306,8 +340,11 @@ class XmlTest extends CakeTestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$obj = Xml::fromArray($xml, 'tags');
|
$obj = Xml::fromArray($xml, 'tags');
|
||||||
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?><tags>All tags<tag id="1">Tag 1<name>defect</name></tag><tag id="2"><name>enhancement</name></tag></tags>';
|
$xmlText = <<<XML
|
||||||
$this->assertEquals(str_replace(array("\r", "\n"), '', $obj->asXML()), $xmlText);
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<tags>All tags<tag id="1">Tag 1<name>defect</name></tag><tag id="2"><name>enhancement</name></tag></tags>
|
||||||
|
XML;
|
||||||
|
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
|
||||||
|
|
||||||
$xml = array(
|
$xml = array(
|
||||||
'tags' => array(
|
'tags' => array(
|
||||||
|
@ -319,7 +356,44 @@ class XmlTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$obj = Xml::fromArray($xml, 'attributes');
|
$obj = Xml::fromArray($xml, 'attributes');
|
||||||
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?><tags><tag id="1">defect</tag></tags>';
|
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?><tags><tag id="1">defect</tag></tags>';
|
||||||
$this->assertEquals(str_replace(array("\r", "\n"), '', $obj->asXML()), $xmlText);
|
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test non-sequential keys in list types.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testFromArrayNonSequentialKeys() {
|
||||||
|
$xmlArray = array(
|
||||||
|
'Event' => array(
|
||||||
|
array(
|
||||||
|
'id' => '235',
|
||||||
|
'Attribute' => array(
|
||||||
|
0 => array(
|
||||||
|
'id' => '9646',
|
||||||
|
),
|
||||||
|
2 => array(
|
||||||
|
'id' => '9647',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$obj = Xml::fromArray($xmlArray);
|
||||||
|
$expected = <<<XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Event>
|
||||||
|
<id>235</id>
|
||||||
|
<Attribute>
|
||||||
|
<id>9646</id>
|
||||||
|
</Attribute>
|
||||||
|
<Attribute>
|
||||||
|
<id>9647</id>
|
||||||
|
</Attribute>
|
||||||
|
</Event>
|
||||||
|
XML;
|
||||||
|
$this->assertXmlStringEqualsXmlString($expected, $obj->asXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -477,9 +551,11 @@ class XmlTest extends CakeTestCase {
|
||||||
$this->assertEquals($expected, Xml::toArray(Xml::fromArray($array, 'attributes')));
|
$this->assertEquals($expected, Xml::toArray(Xml::fromArray($array, 'attributes')));
|
||||||
$this->assertEquals($expected, Xml::toArray(Xml::fromArray($array, array('format' => 'attributes', 'return' => 'domdocument'))));
|
$this->assertEquals($expected, Xml::toArray(Xml::fromArray($array, array('format' => 'attributes', 'return' => 'domdocument'))));
|
||||||
|
|
||||||
$xml = '<root>';
|
$xml = <<<XML
|
||||||
$xml .= '<tag id="1">defect</tag>';
|
<root>
|
||||||
$xml .= '</root>';
|
<tag id="1">defect</tag>
|
||||||
|
</root>
|
||||||
|
XML;
|
||||||
$obj = Xml::build($xml);
|
$obj = Xml::build($xml);
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
|
@ -492,11 +568,13 @@ class XmlTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertEquals($expected, Xml::toArray($obj));
|
$this->assertEquals($expected, Xml::toArray($obj));
|
||||||
|
|
||||||
$xml = '<root>';
|
$xml = <<<XML
|
||||||
$xml .= '<table xmlns="http://www.w3.org/TR/html4/"><tr><td>Apples</td><td>Bananas</td></tr></table>';
|
<root>
|
||||||
$xml .= '<table xmlns="http://www.cakephp.org"><name>CakePHP</name><license>MIT</license></table>';
|
<table xmlns="http://www.w3.org/TR/html4/"><tr><td>Apples</td><td>Bananas</td></tr></table>
|
||||||
$xml .= '<table>The book is on the table.</table>';
|
<table xmlns="http://www.cakephp.org"><name>CakePHP</name><license>MIT</license></table>
|
||||||
$xml .= '</root>';
|
<table>The book is on the table.</table>
|
||||||
|
</root>
|
||||||
|
XML;
|
||||||
$obj = Xml::build($xml);
|
$obj = Xml::build($xml);
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
|
@ -510,10 +588,12 @@ class XmlTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertEquals($expected, Xml::toArray($obj));
|
$this->assertEquals($expected, Xml::toArray($obj));
|
||||||
|
|
||||||
$xml = '<root xmlns:cake="http://www.cakephp.org/">';
|
$xml = <<<XML
|
||||||
$xml .= '<tag>defect</tag>';
|
<root xmlns:cake="http://www.cakephp.org/">
|
||||||
$xml .= '<cake:bug>1</cake:bug>';
|
<tag>defect</tag>
|
||||||
$xml .= '</root>';
|
<cake:bug>1</cake:bug>
|
||||||
|
</root>
|
||||||
|
XML;
|
||||||
$obj = Xml::build($xml);
|
$obj = Xml::build($xml);
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
|
@ -577,18 +657,27 @@ class XmlTest extends CakeTestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$rssAsSimpleXML = Xml::fromArray($rss);
|
$rssAsSimpleXML = Xml::fromArray($rss);
|
||||||
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?>';
|
$xmlText = <<<XML
|
||||||
$xmlText .= '<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">';
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
$xmlText .= '<channel>';
|
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
|
||||||
$xmlText .= '<atom:link href="http://bakery.cakephp.org/articles/rss" rel="self" type="application/rss+xml"/>';
|
<channel>
|
||||||
$xmlText .= '<title>The Bakery: </title>';
|
<atom:link href="http://bakery.cakephp.org/articles/rss" rel="self" type="application/rss+xml"/>
|
||||||
$xmlText .= '<link>http://bakery.cakephp.org/</link>';
|
<title>The Bakery: </title>
|
||||||
$xmlText .= '<description>Recent Articles at The Bakery.</description>';
|
<link>http://bakery.cakephp.org/</link>
|
||||||
$xmlText .= '<pubDate>Sun, 12 Sep 2010 04:18:26 -0500</pubDate>';
|
<description>Recent Articles at The Bakery.</description>
|
||||||
$xmlText .= '<item><title>CakePHP 1.3.4 released</title><link>http://bakery.cakephp.org/articles/view/cakephp-1-3-4-released</link></item>';
|
<pubDate>Sun, 12 Sep 2010 04:18:26 -0500</pubDate>
|
||||||
$xmlText .= '<item><title>Wizard Component 1.2 Tutorial</title><link>http://bakery.cakephp.org/articles/view/wizard-component-1-2-tutorial</link></item>';
|
<item>
|
||||||
$xmlText .= '</channel></rss>';
|
<title>CakePHP 1.3.4 released</title>
|
||||||
$this->assertEquals(str_replace(array("\r", "\n"), '', $rssAsSimpleXML->asXML()), $xmlText);
|
<link>http://bakery.cakephp.org/articles/view/cakephp-1-3-4-released</link>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Wizard Component 1.2 Tutorial</title>
|
||||||
|
<link>http://bakery.cakephp.org/articles/view/wizard-component-1-2-tutorial</link>
|
||||||
|
</item>
|
||||||
|
</channel>
|
||||||
|
</rss>
|
||||||
|
XML;
|
||||||
|
$this->assertXmlStringEqualsXmlString($xmlText, $rssAsSimpleXML->asXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -630,7 +719,27 @@ class XmlTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertSame(Xml::toArray($xml), $expected);
|
$this->assertSame(Xml::toArray($xml), $expected);
|
||||||
|
|
||||||
$xmlText = '<?xml version="1.0" encoding="UTF-8"?><methodResponse><params><param><value><array><data><value><int>1</int></value><value><string>testing</string></value></data></array></value></param></params></methodResponse>';
|
$xmlText = <<<XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<methodResponse>
|
||||||
|
<params>
|
||||||
|
<param>
|
||||||
|
<value>
|
||||||
|
<array>
|
||||||
|
<data>
|
||||||
|
<value>
|
||||||
|
<int>1</int>
|
||||||
|
</value>
|
||||||
|
<value>
|
||||||
|
<string>testing</string>
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
</array>
|
||||||
|
</value>
|
||||||
|
</param>
|
||||||
|
</params>
|
||||||
|
</methodResponse>
|
||||||
|
XML;
|
||||||
$xml = Xml::build($xmlText);
|
$xml = Xml::build($xmlText);
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'methodResponse' => array(
|
'methodResponse' => array(
|
||||||
|
@ -653,7 +762,7 @@ class XmlTest extends CakeTestCase {
|
||||||
$this->assertSame(Xml::toArray($xml), $expected);
|
$this->assertSame(Xml::toArray($xml), $expected);
|
||||||
|
|
||||||
$xml = Xml::fromArray($expected, 'tags');
|
$xml = Xml::fromArray($expected, 'tags');
|
||||||
$this->assertEquals(str_replace(array("\r", "\n"), '', $xml->asXML()), $xmlText);
|
$this->assertXmlStringEqualsXmlString($xmlText, $xml->asXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -701,12 +810,15 @@ class XmlTest extends CakeTestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$xmlRequest = Xml::fromArray($xml, array('encoding' => null));
|
$xmlRequest = Xml::fromArray($xml, array('encoding' => null));
|
||||||
$xmlText = '<' . '?xml version="1.0"?>';
|
$xmlText = <<<XML
|
||||||
$xmlText .= '<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">';
|
<?xml version="1.0"?>
|
||||||
$xmlText .= '<soap:Body xmlns:m="http://www.example.org/stock">';
|
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
|
||||||
$xmlText .= '<m:GetStockPrice><m:StockName>IBM</m:StockName></m:GetStockPrice>';
|
<soap:Body xmlns:m="http://www.example.org/stock">
|
||||||
$xmlText .= '</soap:Body></soap:Envelope>';
|
<m:GetStockPrice><m:StockName>IBM</m:StockName></m:GetStockPrice>
|
||||||
$this->assertEquals(str_replace(array("\r", "\n"), '', $xmlRequest->asXML()), $xmlText);
|
</soap:Body>
|
||||||
|
</soap:Envelope>
|
||||||
|
XML;
|
||||||
|
$this->assertXmlStringEqualsXmlString($xmlText, $xmlRequest->asXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -715,7 +827,16 @@ class XmlTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testNamespace() {
|
public function testNamespace() {
|
||||||
$xmlResponse = Xml::build('<root xmlns:ns="http://cakephp.org"><ns:tag id="1"><child>good</child><otherchild>bad</otherchild></ns:tag><tag>Tag without ns</tag></root>');
|
$xml = <<<XML
|
||||||
|
<root xmlns:ns="http://cakephp.org">
|
||||||
|
<ns:tag id="1">
|
||||||
|
<child>good</child>
|
||||||
|
<otherchild>bad</otherchild>
|
||||||
|
</ns:tag>
|
||||||
|
<tag>Tag without ns</tag>
|
||||||
|
</root>
|
||||||
|
XML;
|
||||||
|
$xmlResponse = Xml::build($xml);
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'root' => array(
|
'root' => array(
|
||||||
'ns:tag' => array(
|
'ns:tag' => array(
|
||||||
|
@ -775,9 +896,17 @@ class XmlTest extends CakeTestCase {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><root><tag xmlns:pref="http://cakephp.org"><pref:item>item 1</pref:item><pref:item>item 2</pref:item></tag></root>';
|
$expected = <<<XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<root>
|
||||||
|
<tag xmlns:pref="http://cakephp.org">
|
||||||
|
<pref:item>item 1</pref:item>
|
||||||
|
<pref:item>item 2</pref:item>
|
||||||
|
</tag>
|
||||||
|
</root>
|
||||||
|
XML;
|
||||||
$xmlResponse = Xml::fromArray($xml);
|
$xmlResponse = Xml::fromArray($xml);
|
||||||
$this->assertEquals(str_replace(array("\r", "\n"), '', $xmlResponse->asXML()), $expected);
|
$this->assertXmlStringEqualsXmlString($expected, $xmlResponse->asXML());
|
||||||
|
|
||||||
$xml = array(
|
$xml = array(
|
||||||
'root' => array(
|
'root' => array(
|
||||||
|
@ -788,7 +917,7 @@ class XmlTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><root><tag xmlns="http://cakephp.org"/></root>';
|
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><root><tag xmlns="http://cakephp.org"/></root>';
|
||||||
$xmlResponse = Xml::fromArray($xml);
|
$xmlResponse = Xml::fromArray($xml);
|
||||||
$this->assertEquals(str_replace(array("\r", "\n"), '', $xmlResponse->asXML()), $expected);
|
$this->assertXmlStringEqualsXmlString($expected, $xmlResponse->asXML());
|
||||||
|
|
||||||
$xml = array(
|
$xml = array(
|
||||||
'root' => array(
|
'root' => array(
|
||||||
|
@ -797,7 +926,7 @@ class XmlTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><root xmlns="http://cakephp.org"/>';
|
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><root xmlns="http://cakephp.org"/>';
|
||||||
$xmlResponse = Xml::fromArray($xml);
|
$xmlResponse = Xml::fromArray($xml);
|
||||||
$this->assertEquals(str_replace(array("\r", "\n"), '', $xmlResponse->asXML()), $expected);
|
$this->assertXmlStringEqualsXmlString($expected, $xmlResponse->asXML());
|
||||||
|
|
||||||
$xml = array(
|
$xml = array(
|
||||||
'root' => array(
|
'root' => array(
|
||||||
|
@ -806,7 +935,7 @@ class XmlTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><root xmlns:ns="http://cakephp.org"/>';
|
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><root xmlns:ns="http://cakephp.org"/>';
|
||||||
$xmlResponse = Xml::fromArray($xml);
|
$xmlResponse = Xml::fromArray($xml);
|
||||||
$this->assertEquals(str_replace(array("\r", "\n"), '', $xmlResponse->asXML()), $expected);
|
$this->assertXmlStringEqualsXmlString($expected, $xmlResponse->asXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -856,34 +985,38 @@ class XmlTest extends CakeTestCase {
|
||||||
$data = $user->read(null, 1);
|
$data = $user->read(null, 1);
|
||||||
|
|
||||||
$obj = Xml::build(compact('data'));
|
$obj = Xml::build(compact('data'));
|
||||||
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><data>';
|
$expected = <<<XML
|
||||||
$expected .= '<User><id>1</id><user>mariano</user><password>5f4dcc3b5aa765d61d8327deb882cf99</password>';
|
<?xml version="1.0" encoding="UTF-8"?><data>
|
||||||
$expected .= '<created>2007-03-17 01:16:23</created><updated>2007-03-17 01:18:31</updated></User>';
|
<User><id>1</id><user>mariano</user><password>5f4dcc3b5aa765d61d8327deb882cf99</password>
|
||||||
$expected .= '<Article><id>1</id><user_id>1</user_id><title>First Article</title><body>First Article Body</body>';
|
<created>2007-03-17 01:16:23</created><updated>2007-03-17 01:18:31</updated></User>
|
||||||
$expected .= '<published>Y</published><created>2007-03-18 10:39:23</created><updated>2007-03-18 10:41:31</updated></Article>';
|
<Article><id>1</id><user_id>1</user_id><title>First Article</title><body>First Article Body</body>
|
||||||
$expected .= '<Article><id>3</id><user_id>1</user_id><title>Third Article</title><body>Third Article Body</body>';
|
<published>Y</published><created>2007-03-18 10:39:23</created><updated>2007-03-18 10:41:31</updated></Article>
|
||||||
$expected .= '<published>Y</published><created>2007-03-18 10:43:23</created><updated>2007-03-18 10:45:31</updated></Article>';
|
<Article><id>3</id><user_id>1</user_id><title>Third Article</title><body>Third Article Body</body>
|
||||||
$expected .= '</data>';
|
<published>Y</published><created>2007-03-18 10:43:23</created><updated>2007-03-18 10:45:31</updated></Article>
|
||||||
$this->assertEquals($expected, str_replace(array("\r", "\n"), '', $obj->asXML()));
|
</data>
|
||||||
|
XML;
|
||||||
|
$this->assertXmlStringEqualsXmlString($expected, $obj->asXML());
|
||||||
|
|
||||||
//multiple model results - without a records key it would fatal error
|
//multiple model results - without a records key it would fatal error
|
||||||
$data = $user->find('all', array('limit' => 2));
|
$data = $user->find('all', array('limit' => 2));
|
||||||
$data = array('records' => $data);
|
$data = array('records' => $data);
|
||||||
$obj = Xml::build(compact('data'));
|
$obj = Xml::build(compact('data'));
|
||||||
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><data>';
|
$expected = <<<XML
|
||||||
$expected .= '<records>';
|
<?xml version="1.0" encoding="UTF-8"?><data>
|
||||||
$expected .= '<User><id>1</id><user>mariano</user><password>5f4dcc3b5aa765d61d8327deb882cf99</password>';
|
<records>
|
||||||
$expected .= '<created>2007-03-17 01:16:23</created><updated>2007-03-17 01:18:31</updated></User>';
|
<User><id>1</id><user>mariano</user><password>5f4dcc3b5aa765d61d8327deb882cf99</password>
|
||||||
$expected .= '<Article><id>1</id><user_id>1</user_id><title>First Article</title><body>First Article Body</body>';
|
<created>2007-03-17 01:16:23</created><updated>2007-03-17 01:18:31</updated></User>
|
||||||
$expected .= '<published>Y</published><created>2007-03-18 10:39:23</created><updated>2007-03-18 10:41:31</updated></Article>';
|
<Article><id>1</id><user_id>1</user_id><title>First Article</title><body>First Article Body</body>
|
||||||
$expected .= '<Article><id>3</id><user_id>1</user_id><title>Third Article</title><body>Third Article Body</body>';
|
<published>Y</published><created>2007-03-18 10:39:23</created><updated>2007-03-18 10:41:31</updated></Article>
|
||||||
$expected .= '<published>Y</published><created>2007-03-18 10:43:23</created><updated>2007-03-18 10:45:31</updated></Article>';
|
<Article><id>3</id><user_id>1</user_id><title>Third Article</title><body>Third Article Body</body>
|
||||||
$expected .= '</records><records><User><id>2</id><user>nate</user><password>5f4dcc3b5aa765d61d8327deb882cf99</password>';
|
<published>Y</published><created>2007-03-18 10:43:23</created><updated>2007-03-18 10:45:31</updated></Article>
|
||||||
$expected .= '<created>2007-03-17 01:18:23</created><updated>2007-03-17 01:20:31</updated></User><Article/>';
|
</records><records><User><id>2</id><user>nate</user><password>5f4dcc3b5aa765d61d8327deb882cf99</password>
|
||||||
$expected .= '</records>';
|
<created>2007-03-17 01:18:23</created><updated>2007-03-17 01:20:31</updated></User><Article/>
|
||||||
$expected .= '</data>';
|
</records>
|
||||||
|
</data>
|
||||||
|
XML;
|
||||||
$result = $obj->asXML();
|
$result = $obj->asXML();
|
||||||
$this->assertEquals($expected, str_replace(array("\r", "\n"), '', $obj->asXML()));
|
$this->assertXmlStringEqualsXmlString($expected, $obj->asXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -901,4 +1034,5 @@ class XmlTest extends CakeTestCase {
|
||||||
$result = $obj->asXml();
|
$result = $obj->asXml();
|
||||||
$this->assertContains('mark & mark', $result);
|
$this->assertContains('mark & mark', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,6 +218,8 @@ abstract class ControllerTestCase extends CakeTestCase {
|
||||||
'return' => 'result'
|
'return' => 'result'
|
||||||
), $options);
|
), $options);
|
||||||
|
|
||||||
|
$restore = array('get' => $_GET, 'post' => $_POST);
|
||||||
|
|
||||||
$_SERVER['REQUEST_METHOD'] = strtoupper($options['method']);
|
$_SERVER['REQUEST_METHOD'] = strtoupper($options['method']);
|
||||||
if (is_array($options['data'])) {
|
if (is_array($options['data'])) {
|
||||||
if (strtoupper($options['method']) == 'GET') {
|
if (strtoupper($options['method']) == 'GET') {
|
||||||
|
@ -273,6 +275,10 @@ abstract class ControllerTestCase extends CakeTestCase {
|
||||||
}
|
}
|
||||||
$this->__dirtyController = true;
|
$this->__dirtyController = true;
|
||||||
$this->headers = $Dispatch->response->header();
|
$this->headers = $Dispatch->response->header();
|
||||||
|
|
||||||
|
$_GET = $restore['get'];
|
||||||
|
$_POST = $restore['post'];
|
||||||
|
|
||||||
return $this->{$options['return']};
|
return $this->{$options['return']};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ class Xml {
|
||||||
if ($key[0] === '@') {
|
if ($key[0] === '@') {
|
||||||
throw new XmlException(__d('cake_dev', 'Invalid array'));
|
throw new XmlException(__d('cake_dev', 'Invalid array'));
|
||||||
}
|
}
|
||||||
if (array_keys($value) === range(0, count($value) - 1)) { // List
|
if (is_numeric(implode(array_keys($value), ''))) { // List
|
||||||
foreach ($value as $item) {
|
foreach ($value as $item) {
|
||||||
$itemData = compact('dom', 'node', 'key', 'format');
|
$itemData = compact('dom', 'node', 'key', 'format');
|
||||||
$itemData['value'] = $item;
|
$itemData['value'] = $item;
|
||||||
|
|
Loading…
Reference in a new issue