@@ -665,4 +665,49 @@ public function testApplyToCollectionNoPartial()
665
665
$ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 );
666
666
$ eagerExtensionTest ->applyToCollection ($ queryBuilder , new QueryNameGenerator (), Dummy::class);
667
667
}
668
+
669
+ public function testApplyToCollectionWithANonRedableButFetchEagerProperty ()
670
+ {
671
+ $ resourceMetadataFactoryProphecy = $ this ->prophesize (ResourceMetadataFactoryInterface::class);
672
+ $ resourceMetadataFactoryProphecy ->create (Dummy::class)->willReturn (new ResourceMetadata ());
673
+
674
+ $ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
675
+
676
+ $ relatedNameCollection = new PropertyNameCollection (['id ' , 'name ' , 'notindatabase ' , 'notreadable ' ]);
677
+
678
+ $ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
679
+ $ relationPropertyMetadata = new PropertyMetadata ();
680
+ $ relationPropertyMetadata = $ relationPropertyMetadata ->withAttributes (['fetchEager ' => true ]);
681
+ $ relationPropertyMetadata = $ relationPropertyMetadata ->withReadableLink (false );
682
+ $ relationPropertyMetadata = $ relationPropertyMetadata ->withReadable (false );
683
+
684
+ $ propertyMetadataFactoryProphecy ->create (Dummy::class, 'relatedDummy ' , [])->willReturn ($ relationPropertyMetadata )->shouldBeCalled ();
685
+ $ propertyMetadataFactoryProphecy ->create (Dummy::class, 'relatedDummy2 ' , [])->willReturn ($ relationPropertyMetadata )->shouldBeCalled ();
686
+
687
+ $ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
688
+
689
+ $ classMetadataProphecy = $ this ->prophesize (ClassMetadata::class);
690
+ $ classMetadataProphecy ->associationMappings = [
691
+ 'relatedDummy ' => ['fetch ' => 3 , 'joinColumns ' => [['nullable ' => true ]], 'targetEntity ' => RelatedDummy::class],
692
+ 'relatedDummy2 ' => ['fetch ' => 3 , 'joinColumns ' => [['nullable ' => false ]], 'targetEntity ' => RelatedDummy::class],
693
+ ];
694
+
695
+ $ emProphecy = $ this ->prophesize (EntityManager::class);
696
+ $ relatedClassMetadataProphecy = $ this ->prophesize (ClassMetadata::class);
697
+ $ relatedClassMetadataProphecy ->associationMappings = [];
698
+ $ emProphecy ->getClassMetadata (Dummy::class)->shouldBeCalled ()->willReturn ($ classMetadataProphecy ->reveal ());
699
+ $ emProphecy ->getClassMetadata (RelatedDummy::class)->shouldBeCalled ()->willReturn ($ relatedClassMetadataProphecy ->reveal ());
700
+
701
+ $ queryBuilderProphecy ->getRootAliases ()->willReturn (['o ' ]);
702
+ $ queryBuilderProphecy ->getEntityManager ()->willReturn ($ emProphecy );
703
+
704
+ $ queryBuilderProphecy ->leftJoin ('o.relatedDummy ' , 'relatedDummy_a1 ' )->shouldBeCalled (1 );
705
+ $ queryBuilderProphecy ->innerJoin ('o.relatedDummy2 ' , 'relatedDummy2_a2 ' )->shouldBeCalled (1 );
706
+ $ queryBuilderProphecy ->addSelect ('relatedDummy_a1 ' )->shouldBeCalled (1 );
707
+ $ queryBuilderProphecy ->addSelect ('relatedDummy2_a2 ' )->shouldBeCalled (1 );
708
+
709
+ $ queryBuilder = $ queryBuilderProphecy ->reveal ();
710
+ $ eagerExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), 30 );
711
+ $ eagerExtensionTest ->applyToCollection ($ queryBuilder , new QueryNameGenerator (), Dummy::class);
712
+ }
668
713
}
0 commit comments