Permalink
Browse files

Add test for XML.

Test xml with multiple model results
Fixes #2304
  • Loading branch information...
dereuromark authored and markstory committed Nov 26, 2011
1 parent a516268 commit fb3d3ca943c05f255d4be86111cf000d71085998
Showing with 19 additions and 0 deletions.
  1. +19 −0 lib/Cake/Test/Case/Utility/XmlTest.php
@@ -865,6 +865,25 @@ public function testWithModel() {
$expected .= '<published>Y</published><created>2007-03-18 10:43:23</created><updated>2007-03-18 10:45:31</updated></Article>';
$expected .= '</data>';
$this->assertEquals(str_replace(array("\r", "\n"), '', $obj->asXML()), $expected);
//multiple model results - without a records key it would fatal error
$data = $user->find('all', array('limit'=>2));
$data = array('records'=>$data);
$obj = Xml::build(compact('data'));
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><data>';
$expected .= '<records>';
$expected .= '<User><id>1</id><user>mariano</user><password>5f4dcc3b5aa765d61d8327deb882cf99</password>';
$expected .= '<created>2007-03-17 01:16:23</created><updated>2007-03-17 01:18:31</updated></User>';
$expected .= '<Article><id>1</id><user_id>1</user_id><title>First Article</title><body>First Article Body</body>';
$expected .= '<published>Y</published><created>2007-03-18 10:39:23</created><updated>2007-03-18 10:41:31</updated></Article>';
$expected .= '<Article><id>3</id><user_id>1</user_id><title>Third Article</title><body>Third Article Body</body>';
$expected .= '<published>Y</published><created>2007-03-18 10:43:23</created><updated>2007-03-18 10:45:31</updated></Article>';
$expected .= '</records><records><User><id>2</id><user>nate</user><password>5f4dcc3b5aa765d61d8327deb882cf99</password>';
$expected .= '<created>2007-03-17 01:18:23</created><updated>2007-03-17 01:20:31</updated></User><Article/>';
$expected .= '</records>';
$expected .= '</data>';
$result = $obj->asXML();
$this->assertEquals(str_replace(array("\r", "\n"), '', $obj->asXML()), $expected);
}
/**

0 comments on commit fb3d3ca

Please sign in to comment.