3131use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \EmbeddableDummy ;
3232use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \RelatedDummy ;
3333use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \UnknownDummy ;
34- use Doctrine \ORM \AbstractQuery ;
3534use Doctrine \ORM \EntityManager ;
3635use Doctrine \ORM \Mapping \ClassMetadata ;
3736use Doctrine \ORM \Mapping \ClassMetadataInfo ;
@@ -123,9 +122,6 @@ public function testApplyToCollection()
123122 $ queryBuilderProphecy ->addSelect ('partial relatedDummy_a1.{id,name,embeddedDummy.name} ' )->shouldBeCalled (1 );
124123 $ queryBuilderProphecy ->addSelect ('partial relatedDummy2_a2.{id,name,embeddedDummy.name} ' )->shouldBeCalled (1 );
125124
126- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
127- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (3 );
128-
129125 $ queryBuilder = $ queryBuilderProphecy ->reveal ();
130126 $ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true );
131127 $ eagerExtensionTest ->applyToCollection ($ queryBuilder , new QueryNameGenerator (), Dummy::class, null , $ context );
@@ -232,9 +228,6 @@ public function testApplyToItem()
232228 $ queryBuilderProphecy ->addSelect ('partial relatedDummy4_a5.{id} ' )->shouldBeCalled (1 );
233229 $ queryBuilderProphecy ->addSelect ('singleInheritanceRelation_a6 ' )->shouldBeCalled (1 );
234230
235- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
236- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (7 );
237-
238231 $ queryBuilder = $ queryBuilderProphecy ->reveal ();
239232 $ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true );
240233
@@ -260,8 +253,6 @@ public function testCreateItemWithOperationName()
260253 $ emProphecy ->getClassMetadata (Dummy::class)->shouldBeCalled ()->willReturn ($ classMetadataProphecy ->reveal ());
261254 $ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
262255 $ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
263- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
264- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
265256
266257 $ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true );
267258 $ orderExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, [], 'item_operation ' , ['groups ' => ['foo ' ]]);
@@ -286,8 +277,6 @@ public function testCreateCollectionWithOperationName()
286277 $ emProphecy ->getClassMetadata (Dummy::class)->shouldBeCalled ()->willReturn ($ classMetadataProphecy ->reveal ());
287278 $ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
288279 $ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
289- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
290- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
291280
292281 $ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true );
293282 $ eagerExtensionTest ->applyToCollection ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, 'collection_operation ' , ['groups ' => ['foo ' ]]);
@@ -311,8 +300,6 @@ public function testDenormalizeItemWithCorrectResourceClass()
311300 $ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
312301 $ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
313302 $ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
314- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
315- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
316303
317304 $ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true );
318305 $ eagerExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), RelatedDummy::class, ['id ' => 1 ], 'item_operation ' , ['resource_class ' => Dummy::class]);
@@ -335,8 +322,6 @@ public function testDenormalizeItemWithExistingGroups()
335322 $ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
336323 $ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
337324 $ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
338- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
339- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
340325
341326 $ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true );
342327 $ eagerExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), RelatedDummy::class, ['id ' => 1 ], 'item_operation ' , [AbstractNormalizer::GROUPS => 'some_groups ' ]);
@@ -457,8 +442,6 @@ public function testMaxDepth()
457442
458443 $ queryBuilderProphecy ->innerJoin (Argument::type ('string ' ), Argument::type ('string ' ))->shouldBeCalledTimes (2 );
459444 $ queryBuilderProphecy ->addSelect (Argument::type ('string ' ))->shouldBeCalled ();
460- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
461- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (3 );
462445
463446 $ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , false , null , null , true , $ classMetadataFactoryProphecy ->reveal ());
464447 $ eagerExtensionTest ->applyToCollection ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class);
@@ -504,9 +487,6 @@ public function testForceEager()
504487 $ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
505488 $ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
506489
507- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
508- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (2 );
509-
510490 $ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , true , null , null , true );
511491 $ orderExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, []);
512492 }
@@ -543,9 +523,6 @@ public function testExtraLazy()
543523 $ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
544524 $ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
545525
546- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
547- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
548-
549526 $ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , true , null , null , true );
550527 $ orderExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, []);
551528 }
@@ -569,8 +546,6 @@ public function testResourceClassNotFoundException()
569546 $ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
570547 $ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
571548 $ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
572- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
573- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
574549
575550 $ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , true , null , null , true );
576551 $ orderExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, [], null );
@@ -595,8 +570,6 @@ public function testPropertyNotFoundException()
595570 $ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
596571 $ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
597572 $ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
598- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
599- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
600573
601574 $ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , true , null , null , true );
602575 $ orderExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, []);
@@ -626,8 +599,6 @@ public function testResourceClassNotFoundExceptionPropertyNameCollection()
626599 $ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
627600 $ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
628601 $ queryBuilderProphecy ->innerJoin ('o.relation ' , 'relation_a1 ' )->shouldBeCalled (1 );
629- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
630- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
631602
632603 $ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 , true , null , null , true );
633604 $ orderExtensionTest ->applyToItem ($ queryBuilderProphecy ->reveal (), new QueryNameGenerator (), Dummy::class, []);
@@ -683,8 +654,6 @@ public function testApplyToCollectionWithSerializerContextBuilder()
683654
684655 $ queryBuilderProphecy ->leftJoin ('o.relatedDummy ' , 'relatedDummy_a1 ' )->shouldBeCalled (1 );
685656 $ queryBuilderProphecy ->addSelect ('partial relatedDummy_a1.{id,name} ' )->shouldBeCalled (1 );
686- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
687- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (2 );
688657
689658 $ request = Request::create ('/api/dummies ' , 'GET ' , []);
690659
@@ -749,8 +718,6 @@ public function testAttributes()
749718
750719 $ queryBuilderProphecy ->leftJoin ('o.relatedDummy ' , 'relatedDummy_a1 ' )->shouldBeCalled (1 );
751720 $ queryBuilderProphecy ->addSelect ('partial relatedDummy_a1.{id,name} ' )->shouldBeCalled (1 );
752- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
753- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (2 );
754721
755722 $ request = Request::create ('/api/dummies ' , 'GET ' , []);
756723
@@ -792,8 +759,6 @@ public function testNotInAttributes()
792759
793760 $ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
794761 $ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
795- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
796- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
797762
798763 $ request = Request::create ('/api/dummies ' , 'GET ' , []);
799764
@@ -843,8 +808,6 @@ public function testApplyToCollectionNoPartial()
843808 $ queryBuilderProphecy ->innerJoin ('o.relatedDummy2 ' , 'relatedDummy2_a2 ' )->shouldBeCalled (1 );
844809 $ queryBuilderProphecy ->addSelect ('relatedDummy_a1 ' )->shouldBeCalled (1 );
845810 $ queryBuilderProphecy ->addSelect ('relatedDummy2_a2 ' )->shouldBeCalled (1 );
846- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
847- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (3 );
848811
849812 $ queryBuilder = $ queryBuilderProphecy ->reveal ();
850813 $ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 );
@@ -901,8 +864,6 @@ private function doTestApplyToCollectionWithANonRedableButFetchEagerProperty(boo
901864 $ queryBuilderProphecy ->innerJoin ('o.relatedDummy2 ' , 'relatedDummy2_a2 ' )->shouldBeCalled (1 );
902865 $ queryBuilderProphecy ->addSelect ('relatedDummy_a1 ' )->shouldBeCalled (1 );
903866 $ queryBuilderProphecy ->addSelect ('relatedDummy2_a2 ' )->shouldBeCalled (1 );
904- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
905- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (3 );
906867
907868 $ queryBuilder = $ queryBuilderProphecy ->reveal ();
908869 $ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 );
@@ -957,8 +918,6 @@ private function doTestApplyToCollectionWithARedableButNotFetchEagerProperty(boo
957918 $ queryBuilderProphecy ->innerJoin ('o.relatedDummy2 ' , 'relatedDummy2_a2 ' )->shouldNotBeCalled ();
958919 $ queryBuilderProphecy ->addSelect ('relatedDummy_a1 ' )->shouldNotBeCalled ();
959920 $ queryBuilderProphecy ->addSelect ('relatedDummy2_a2 ' )->shouldNotBeCalled ();
960- $ queryAbstractProphecy = $ this ->prophesize (AbstractQuery::class);
961- $ queryBuilderProphecy ->getQuery ()->willReturn ($ queryAbstractProphecy )->shouldBeCalledTimes (1 );
962921
963922 $ queryBuilder = $ queryBuilderProphecy ->reveal ();
964923 $ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 );
0 commit comments