2
2
3
3
namespace Redmine \Tests \Unit \Api ;
4
4
5
- use DOMDocument ;
6
5
use PHPUnit \Framework \TestCase ;
7
6
use Redmine \Api \AbstractApi ;
8
7
use Redmine \Client \Client ;
@@ -180,16 +179,6 @@ public static function getJsonDecodingFromGetMethodData(): array
180
179
*/
181
180
public function testXmlDecodingFromRequestMethods ($ methodName , $ response , $ decode , $ expected )
182
181
{
183
- $ xmlToString = function (SimpleXMLElement $ xmlElement ) {
184
- $ dom = new DOMDocument ('1.0 ' );
185
- $ dom ->preserveWhiteSpace = false ;
186
- $ dom ->formatOutput = false ;
187
- $ dom ->loadXML ($ xmlElement ->asXML ());
188
-
189
- // Remove line breaks
190
- return preg_replace ("/ \r| \n/ " , '' , $ dom ->saveXML ());
191
- };
192
-
193
182
$ client = $ this ->createMock (Client::class);
194
183
$ client ->method ('getLastResponseBody ' )->willReturn ($ response );
195
184
$ client ->method ('getLastResponseContentType ' )->willReturn ('application/xml ' );
@@ -204,7 +193,7 @@ public function testXmlDecodingFromRequestMethods($methodName, $response, $decod
204
193
$ return = $ method ->invoke ($ api , 'path ' , $ decode );
205
194
206
195
$ this ->assertInstanceOf (SimpleXMLElement::class, $ return );
207
- $ this ->assertSame ($ expected , $ xmlToString ( $ return ));
196
+ $ this ->assertXmlStringEqualsXmlString ($ expected , $ return-> asXML ( ));
208
197
} elseif ('delete ' === $ methodName ) {
209
198
$ return = $ method ->invoke ($ api , 'path ' );
210
199
@@ -213,7 +202,7 @@ public function testXmlDecodingFromRequestMethods($methodName, $response, $decod
213
202
$ return = $ method ->invoke ($ api , 'path ' , '' );
214
203
215
204
$ this ->assertInstanceOf (SimpleXMLElement::class, $ return );
216
- $ this ->assertSame ($ expected , $ xmlToString ( $ return ));
205
+ $ this ->assertXmlStringEqualsXmlString ($ expected , $ return-> asXML ( ));
217
206
}
218
207
}
219
208
@@ -228,4 +217,23 @@ public static function getXmlDecodingFromGetMethodData(): array
228
217
['delete ' , '<?xml version="1.0"?><issue/> ' , null , '<?xml version="1.0"?><issue/> ' ],
229
218
];
230
219
}
220
+
221
+ /**
222
+ * @covers \Redmine\Api\AbstractApi::retrieveAll
223
+ */
224
+ public function testDeprecatedRetrieveAll ()
225
+ {
226
+ $ client = $ this ->createMock (Client::class);
227
+ $ client ->method ('requestGet ' )->willReturn (true );
228
+ $ client ->method ('getLastResponseBody ' )->willReturn ('<?xml version="1.0"?><issue/> ' );
229
+ $ client ->method ('getLastResponseContentType ' )->willReturn ('application/xml ' );
230
+
231
+ $ api = $ this ->getMockForAbstractClass (AbstractApi::class, [$ client ]);
232
+
233
+ $ method = new ReflectionMethod ($ api , 'retrieveAll ' );
234
+ $ method ->setAccessible (true );
235
+
236
+ $ this ->assertSame ([], $ method ->invoke ($ api , '/issues.xml ' ));
237
+
238
+ }
231
239
}
0 commit comments