@@ -300,6 +300,41 @@ public function testApplyToCollectionPaginationDisabled()
300
300
$ extension ->applyToCollection ($ queryBuilder , new QueryNameGenerator (), 'Foo ' , 'op ' );
301
301
}
302
302
303
+ public function testApplyToCollectionWithMaximumItemsPerPage ()
304
+ {
305
+ $ requestStack = new RequestStack ();
306
+ $ requestStack ->push (new Request (['pagination ' => true , 'itemsPerPage ' => 80 , 'page ' => 1 ]));
307
+
308
+ $ resourceMetadataFactoryProphecy = $ this ->prophesize (ResourceMetadataFactoryInterface::class);
309
+ $ attributes = [
310
+ 'pagination_enabled ' => true ,
311
+ 'pagination_client_enabled ' => true ,
312
+ 'maximum_items_per_page ' => 80 ,
313
+ ];
314
+ $ resourceMetadataFactoryProphecy ->create ('Foo ' )->willReturn (new ResourceMetadata (null , null , null , [], [], $ attributes ))->shouldBeCalled ();
315
+ $ resourceMetadataFactory = $ resourceMetadataFactoryProphecy ->reveal ();
316
+
317
+ $ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
318
+ $ queryBuilderProphecy ->setFirstResult (0 )->willReturn ($ queryBuilderProphecy )->shouldBeCalled ();
319
+ $ queryBuilderProphecy ->setMaxResults (80 )->shouldBeCalled ();
320
+ $ queryBuilder = $ queryBuilderProphecy ->reveal ();
321
+
322
+ $ extension = new PaginationExtension (
323
+ $ this ->prophesize (ManagerRegistry::class)->reveal (),
324
+ $ requestStack ,
325
+ $ resourceMetadataFactory ,
326
+ true ,
327
+ true ,
328
+ true ,
329
+ 30 ,
330
+ 'page ' ,
331
+ 'pagination ' ,
332
+ 'itemsPerPage ' ,
333
+ 50
334
+ );
335
+ $ extension ->applyToCollection ($ queryBuilder , new QueryNameGenerator (), 'Foo ' , 'op ' );
336
+ }
337
+
303
338
public function testSupportsResult ()
304
339
{
305
340
$ requestStack = new RequestStack ();
0 commit comments