@@ -43,9 +43,27 @@ public function testRenderWithoutView() {
43
43
$ View = new XmlView ($ Controller );
44
44
$ output = $ View ->render (false );
45
45
46
- $ expected = '<?xml version="1.0" encoding="UTF-8"?> ' . "\n" . '<users><user>user1</user><user>user2</user></users> ' ;
47
- $ this ->assertTextEquals ($ expected , trim ($ output ));
48
- $ this ->assertIdentical ('application/xml ' , $ Response ->type ());
46
+ $ this ->assertSame (Xml::build ($ data )->asXML (), $ output );
47
+ $ this ->assertSame ('application/xml ' , $ Response ->type ());
48
+
49
+ $ data = array (
50
+ array (
51
+ 'User ' => array (
52
+ 'username ' => 'user1 '
53
+ )
54
+ ),
55
+ array (
56
+ 'User ' => array (
57
+ 'username ' => 'user2 '
58
+ )
59
+ )
60
+ );
61
+ $ Controller ->set (array ('users ' => $ data , '_serialize ' => 'users ' ));
62
+ $ View = new XmlView ($ Controller );
63
+ $ output = $ View ->render (false );
64
+
65
+ $ expected = Xml::build (array ('response ' => array ('users ' => $ data )))->asXML ();
66
+ $ this ->assertSame ($ expected , $ output );
49
67
}
50
68
51
69
/**
@@ -100,9 +118,12 @@ public function testRenderWithView() {
100
118
$ View = new XmlView ($ Controller );
101
119
$ output = $ View ->render ('index ' );
102
120
103
- $ expected = '<?xml version="1.0" encoding="UTF-8"?><users><user>user1</user><user>user2</user></users> ' ;
104
- $ this ->assertIdentical ($ expected , str_replace (array ("\r" , "\n" ), '' , $ output ));
105
- $ this ->assertIdentical ('application/xml ' , $ Response ->type ());
121
+ $ expected = array (
122
+ 'users ' => array ('user ' => array ('user1 ' , 'user2 ' ))
123
+ );
124
+ $ expected = Xml::build ($ expected )->asXML ();
125
+ $ this ->assertSame ($ expected , $ output );
126
+ $ this ->assertSame ('application/xml ' , $ Response ->type ());
106
127
$ this ->assertInstanceOf ('HelperCollection ' , $ View ->Helpers );
107
128
}
108
129
0 commit comments