@@ -30,6 +30,19 @@ public function testResponseSimpleList()
30
30
$ this ->assertSame ('{"_embedded":{"articles":["Article 1","Article 2","Article 3"],"news":["News 1","News 2","News 3"]}} ' , $ content );
31
31
}
32
32
33
+ public function testResponseEmptyList ()
34
+ {
35
+ $ content = $ this ->createSendResponse (
36
+ [
37
+ '_embedded ' => [
38
+ 'articles ' => $ this ->generatorSimple ('Article ' , 0 ),
39
+ ],
40
+ ],
41
+ );
42
+
43
+ $ this ->assertSame ('{"_embedded":{"articles":[]}} ' , $ content );
44
+ }
45
+
33
46
public function testResponseObjectsList ()
34
47
{
35
48
$ content = $ this ->createSendResponse (
@@ -222,20 +235,20 @@ private function createSendResponse(array $data): string
222
235
/**
223
236
* @return \Generator<int, string>
224
237
*/
225
- private function generatorSimple (string $ test ): \Generator
238
+ private function generatorSimple (string $ test, int $ length = 3 ): \Generator
226
239
{
227
- yield $ test . ' 1 ' ;
228
- yield $ test .' 2 ' ;
229
- yield $ test . ' 3 ' ;
240
+ for ( $ i = 1 ; $ i <= $ length ; ++ $ i ) {
241
+ yield $ test .' ' . $ i ;
242
+ }
230
243
}
231
244
232
245
/**
233
246
* @return \Generator<int, array{title: string}>
234
247
*/
235
- private function generatorArray (string $ test ): \Generator
248
+ private function generatorArray (string $ test, int $ length = 3 ): \Generator
236
249
{
237
- yield [ ' title ' => $ test . ' 1 ' ];
238
- yield ['title ' => $ test .' 2 ' ];
239
- yield [ ' title ' => $ test . ' 3 ' ];
250
+ for ( $ i = 1 ; $ i <= $ length ; ++ $ i ) {
251
+ yield ['title ' => $ test .' ' . $ i ];
252
+ }
240
253
}
241
254
}
0 commit comments