@@ -398,6 +398,31 @@ public static function retrieveDataData(): array
398
398
];
399
399
}
400
400
401
+ public function testRetrieveDataWith250ResultsMakes3Requests (): void
402
+ {
403
+ $ response1 = $ this ->createStub (Response::class);
404
+ $ response1 ->method ('getContentType ' )->willReturn ('application/json ' );
405
+ $ response1 ->method ('getContent ' )->willReturn ('{"total_count":250,"offset":0,"limit":100,"data":[]} ' );
406
+
407
+ $ response2 = $ this ->createStub (Response::class);
408
+ $ response2 ->method ('getContentType ' )->willReturn ('application/json ' );
409
+ $ response2 ->method ('getContent ' )->willReturn ('{"total_count":250,"offset":100,"limit":100,"data":[]} ' );
410
+
411
+ $ response3 = $ this ->createStub (Response::class);
412
+ $ response3 ->method ('getContentType ' )->willReturn ('application/json ' );
413
+ $ response3 ->method ('getContent ' )->willReturn ('{"total_count":250,"offset":200,"limit":100,"data":[]} ' );
414
+
415
+ $ client = $ this ->createMock (HttpClient::class);
416
+ $ client ->expects ($ this ->exactly (3 ))->method ('request ' )->willReturnOnConsecutiveCalls ($ response1 , $ response2 , $ response3 );
417
+
418
+ $ api = new class ($ client ) extends AbstractApi {};
419
+
420
+ $ method = new ReflectionMethod ($ api , 'retrieveData ' );
421
+ $ method ->setAccessible (true );
422
+
423
+ $ method ->invoke ($ api , '/data.json ' , ['limit ' => 300 ]);
424
+ }
425
+
401
426
/**
402
427
* @dataProvider getRetrieveDataToExceptionData
403
428
*/
0 commit comments