@@ -850,4 +850,45 @@ public function testApplyToCollectionWithANonRedableButFetchEagerProperty()
850
850
$ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 );
851
851
$ eagerExtensionTest ->applyToCollection ($ queryBuilder , new QueryNameGenerator (), Dummy::class);
852
852
}
853
+
854
+ public function testApplyToCollectionWithARedableButNotFetchEagerProperty ()
855
+ {
856
+ $ resourceMetadataFactoryProphecy = $ this ->prophesize (ResourceMetadataFactoryInterface::class);
857
+ $ resourceMetadataFactoryProphecy ->create (Dummy::class)->willReturn (new ResourceMetadata ());
858
+
859
+ $ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
860
+
861
+ $ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
862
+ $ relationPropertyMetadata = new PropertyMetadata ();
863
+ $ relationPropertyMetadata = $ relationPropertyMetadata ->withAttributes (['fetchEager ' => false ]);
864
+ $ relationPropertyMetadata = $ relationPropertyMetadata ->withReadableLink (true );
865
+ $ relationPropertyMetadata = $ relationPropertyMetadata ->withReadable (true );
866
+
867
+ $ propertyMetadataFactoryProphecy ->create (Dummy::class, 'relatedDummy ' , [])->willReturn ($ relationPropertyMetadata )->shouldBeCalled ();
868
+ $ propertyMetadataFactoryProphecy ->create (Dummy::class, 'relatedDummy2 ' , [])->willReturn ($ relationPropertyMetadata )->shouldBeCalled ();
869
+
870
+ $ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
871
+
872
+ $ classMetadataProphecy = $ this ->prophesize (ClassMetadata::class);
873
+ $ classMetadataProphecy ->associationMappings = [
874
+ 'relatedDummy ' => ['fetch ' => ClassMetadataInfo::FETCH_EAGER , 'joinColumns ' => [['nullable ' => true ]], 'targetEntity ' => RelatedDummy::class],
875
+ 'relatedDummy2 ' => ['fetch ' => ClassMetadataInfo::FETCH_EAGER , 'joinColumns ' => [['nullable ' => false ]], 'targetEntity ' => RelatedDummy::class],
876
+ ];
877
+
878
+ $ emProphecy = $ this ->prophesize (EntityManager::class);
879
+ $ emProphecy ->getClassMetadata (Dummy::class)->shouldBeCalled ()->willReturn ($ classMetadataProphecy ->reveal ());
880
+ $ emProphecy ->getClassMetadata (RelatedDummy::class)->shouldNotBecalled ();
881
+
882
+ $ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
883
+ $ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
884
+
885
+ $ queryBuilderProphecy ->leftJoin ('o.relatedDummy ' , 'relatedDummy_a1 ' )->shouldNotBeCalled ();
886
+ $ queryBuilderProphecy ->innerJoin ('o.relatedDummy2 ' , 'relatedDummy2_a2 ' )->shouldNotBeCalled ();
887
+ $ queryBuilderProphecy ->addSelect ('relatedDummy_a1 ' )->shouldNotBeCalled ();
888
+ $ queryBuilderProphecy ->addSelect ('relatedDummy2_a2 ' )->shouldNotBeCalled ();
889
+
890
+ $ queryBuilder = $ queryBuilderProphecy ->reveal ();
891
+ $ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 );
892
+ $ eagerExtensionTest ->applyToCollection ($ queryBuilder , new QueryNameGenerator (), Dummy::class);
893
+ }
853
894
}
0 commit comments