31
31
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \EmbeddableDummy ;
32
32
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \RelatedDummy ;
33
33
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \UnknownDummy ;
34
- use Doctrine \ORM \AbstractQuery ;
35
34
use Doctrine \ORM \EntityManager ;
36
35
use Doctrine \ORM \Mapping \ClassMetadata ;
37
36
use Doctrine \ORM \Mapping \ClassMetadataInfo ;
@@ -123,9 +122,6 @@ public function testApplyToCollection()
123
122
$ queryBuilderProphecy ->addSelect ('partial relatedDummy_a1.{id,name,embeddedDummy.name} ' )->shouldBeCalled (1 );
124
123
$ queryBuilderProphecy ->addSelect ('partial relatedDummy2_a2.{id,name,embeddedDummy.name} ' )->shouldBeCalled (1 );
125
124
126
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
127
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (3 );
128
-
129
125
$ queryBuilder = $ queryBuilderProphecy ->reveal ();
130
126
$ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true );
131
127
$ eagerExtensionTest ->applyToCollection ($ queryBuilder , new QueryNameGenerator (), Dummy::class, null , $ context );
@@ -232,9 +228,6 @@ public function testApplyToItem()
232
228
$ queryBuilderProphecy ->addSelect ('partial relatedDummy4_a5.{id} ' )->shouldBeCalled (1 );
233
229
$ queryBuilderProphecy ->addSelect ('singleInheritanceRelation_a6 ' )->shouldBeCalled (1 );
234
230
235
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
236
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (7 );
237
-
238
231
$ queryBuilder = $ queryBuilderProphecy ->reveal ();
239
232
$ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true );
240
233
@@ -260,8 +253,6 @@ public function testCreateItemWithOperationName()
260
253
$ emProphecy ->getClassMetadata (Dummy::class)->shouldBeCalled ()->willReturn ($ classMetadataProphecy ->reveal ());
261
254
$ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
262
255
$ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
263
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
264
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
265
256
266
257
$ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true );
267
258
$ orderExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, [], 'item_operation ' , ['groups ' => ['foo ' ]]);
@@ -286,8 +277,6 @@ public function testCreateCollectionWithOperationName()
286
277
$ emProphecy ->getClassMetadata (Dummy::class)->shouldBeCalled ()->willReturn ($ classMetadataProphecy ->reveal ());
287
278
$ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
288
279
$ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
289
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
290
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
291
280
292
281
$ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true );
293
282
$ eagerExtensionTest ->applyToCollection ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, 'collection_operation ' , ['groups ' => ['foo ' ]]);
@@ -311,8 +300,6 @@ public function testDenormalizeItemWithCorrectResourceClass()
311
300
$ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
312
301
$ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
313
302
$ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
314
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
315
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
316
303
317
304
$ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true );
318
305
$ eagerExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), RelatedDummy::class, ['id ' => 1 ], 'item_operation ' , ['resource_class ' => Dummy::class]);
@@ -335,8 +322,6 @@ public function testDenormalizeItemWithExistingGroups()
335
322
$ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
336
323
$ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
337
324
$ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
338
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
339
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
340
325
341
326
$ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true );
342
327
$ eagerExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), RelatedDummy::class, ['id ' => 1 ], 'item_operation ' , [AbstractNormalizer::GROUPS => 'some_groups ' ]);
@@ -457,8 +442,6 @@ public function testMaxDepth()
457
442
458
443
$ queryBuilderProphecy ->innerJoin (Argument::type ('string ' ), Argument::type ('string ' ))->shouldBeCalledTimes (2 );
459
444
$ queryBuilderProphecy ->addSelect (Argument::type ('string ' ))->shouldBeCalled ();
460
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
461
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (3 );
462
445
463
446
$ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true , $ classMetadataFactoryProphecy ->reveal ());
464
447
$ eagerExtensionTest ->applyToCollection ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class);
@@ -504,9 +487,6 @@ public function testForceEager()
504
487
$ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
505
488
$ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
506
489
507
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
508
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (2 );
509
-
510
490
$ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , true , null , null , true );
511
491
$ orderExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, []);
512
492
}
@@ -543,9 +523,6 @@ public function testExtraLazy()
543
523
$ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
544
524
$ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
545
525
546
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
547
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
548
-
549
526
$ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , true , null , null , true );
550
527
$ orderExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, []);
551
528
}
@@ -569,8 +546,6 @@ public function testResourceClassNotFoundException()
569
546
$ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
570
547
$ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
571
548
$ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
572
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
573
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
574
549
575
550
$ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , true , null , null , true );
576
551
$ orderExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, [], null );
@@ -595,8 +570,6 @@ public function testPropertyNotFoundException()
595
570
$ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
596
571
$ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
597
572
$ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
598
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
599
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
600
573
601
574
$ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , true , null , null , true );
602
575
$ orderExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, []);
@@ -626,8 +599,6 @@ public function testResourceClassNotFoundExceptionPropertyNameCollection()
626
599
$ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
627
600
$ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
628
601
$ queryBuilderProphecy ->innerJoin ('o.relation ' , 'relation_a1 ' )->shouldBeCalled (1 );
629
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
630
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
631
602
632
603
$ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , true , null , null , true );
633
604
$ orderExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, []);
@@ -683,8 +654,6 @@ public function testApplyToCollectionWithSerializerContextBuilder()
683
654
684
655
$ queryBuilderProphecy ->leftJoin ('o.relatedDummy ' , 'relatedDummy_a1 ' )->shouldBeCalled (1 );
685
656
$ queryBuilderProphecy ->addSelect ('partial relatedDummy_a1.{id,name} ' )->shouldBeCalled (1 );
686
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
687
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (2 );
688
657
689
658
$ request = Request::create ('/api/dummies ' , 'GET ' , []);
690
659
@@ -749,8 +718,6 @@ public function testAttributes()
749
718
750
719
$ queryBuilderProphecy ->leftJoin ('o.relatedDummy ' , 'relatedDummy_a1 ' )->shouldBeCalled (1 );
751
720
$ queryBuilderProphecy ->addSelect ('partial relatedDummy_a1.{id,name} ' )->shouldBeCalled (1 );
752
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
753
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (2 );
754
721
755
722
$ request = Request::create ('/api/dummies ' , 'GET ' , []);
756
723
@@ -792,8 +759,6 @@ public function testNotInAttributes()
792
759
793
760
$ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
794
761
$ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
795
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
796
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
797
762
798
763
$ request = Request::create ('/api/dummies ' , 'GET ' , []);
799
764
@@ -843,8 +808,6 @@ public function testApplyToCollectionNoPartial()
843
808
$ queryBuilderProphecy ->innerJoin ('o.relatedDummy2 ' , 'relatedDummy2_a2 ' )->shouldBeCalled (1 );
844
809
$ queryBuilderProphecy ->addSelect ('relatedDummy_a1 ' )->shouldBeCalled (1 );
845
810
$ queryBuilderProphecy ->addSelect ('relatedDummy2_a2 ' )->shouldBeCalled (1 );
846
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
847
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (3 );
848
811
849
812
$ queryBuilder = $ queryBuilderProphecy ->reveal ();
850
813
$ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 );
@@ -901,8 +864,6 @@ private function doTestApplyToCollectionWithANonRedableButFetchEagerProperty(boo
901
864
$ queryBuilderProphecy ->innerJoin ('o.relatedDummy2 ' , 'relatedDummy2_a2 ' )->shouldBeCalled (1 );
902
865
$ queryBuilderProphecy ->addSelect ('relatedDummy_a1 ' )->shouldBeCalled (1 );
903
866
$ queryBuilderProphecy ->addSelect ('relatedDummy2_a2 ' )->shouldBeCalled (1 );
904
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
905
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (3 );
906
867
907
868
$ queryBuilder = $ queryBuilderProphecy ->reveal ();
908
869
$ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 );
@@ -957,8 +918,6 @@ private function doTestApplyToCollectionWithARedableButNotFetchEagerProperty(boo
957
918
$ queryBuilderProphecy ->innerJoin ('o.relatedDummy2 ' , 'relatedDummy2_a2 ' )->shouldNotBeCalled ();
958
919
$ queryBuilderProphecy ->addSelect ('relatedDummy_a1 ' )->shouldNotBeCalled ();
959
920
$ queryBuilderProphecy ->addSelect ('relatedDummy2_a2 ' )->shouldNotBeCalled ();
960
- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
961
- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
962
921
963
922
$ queryBuilder = $ queryBuilderProphecy ->reveal ();
964
923
$ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 );
0 commit comments