18
18
use ApiPlatform \Core \Metadata \Property \PropertyMetadata ;
19
19
use ApiPlatform \Core \Metadata \Property \PropertyNameCollection ;
20
20
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \Dummy ;
21
- use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \DummyRelated ;
21
+ use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \RelatedDummy ;
22
22
use Doctrine \ORM \EntityManager ;
23
23
use Doctrine \ORM \Mapping \ClassMetadata ;
24
24
use Doctrine \ORM \QueryBuilder ;
@@ -34,7 +34,7 @@ public function testApplyToCollection()
34
34
35
35
$ relatedNameCollection = new PropertyNameCollection (['id ' , 'name ' , 'notindatabase ' , 'notreadable ' ]);
36
36
37
- $ propertyNameCollectionFactoryProphecy ->create (DummyRelated ::class)->willReturn ($ relatedNameCollection )->shouldBeCalled ();
37
+ $ propertyNameCollectionFactoryProphecy ->create (RelatedDummy ::class)->willReturn ($ relatedNameCollection )->shouldBeCalled ();
38
38
39
39
$ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
40
40
$ relationPropertyMetadata = new PropertyMetadata ();
@@ -52,18 +52,18 @@ public function testApplyToCollection()
52
52
$ notReadablePropertyMetadata = new PropertyMetadata ();
53
53
$ notReadablePropertyMetadata = $ notReadablePropertyMetadata ->withReadable (false );
54
54
55
- $ propertyMetadataFactoryProphecy ->create (DummyRelated ::class, 'id ' )->willReturn ($ idPropertyMetadata )->shouldBeCalled ();
56
- $ propertyMetadataFactoryProphecy ->create (DummyRelated ::class, 'name ' )->willReturn ($ namePropertyMetadata )->shouldBeCalled ();
57
- $ propertyMetadataFactoryProphecy ->create (DummyRelated ::class, 'notindatabase ' )->willReturn ($ notInDatabasePropertyMetadata )->shouldBeCalled ();
58
- $ propertyMetadataFactoryProphecy ->create (DummyRelated ::class, 'notreadable ' )->willReturn ($ notReadablePropertyMetadata )->shouldBeCalled ();
55
+ $ propertyMetadataFactoryProphecy ->create (RelatedDummy ::class, 'id ' )->willReturn ($ idPropertyMetadata )->shouldBeCalled ();
56
+ $ propertyMetadataFactoryProphecy ->create (RelatedDummy ::class, 'name ' )->willReturn ($ namePropertyMetadata )->shouldBeCalled ();
57
+ $ propertyMetadataFactoryProphecy ->create (RelatedDummy ::class, 'notindatabase ' )->willReturn ($ notInDatabasePropertyMetadata )->shouldBeCalled ();
58
+ $ propertyMetadataFactoryProphecy ->create (RelatedDummy ::class, 'notreadable ' )->willReturn ($ notReadablePropertyMetadata )->shouldBeCalled ();
59
59
60
60
$ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
61
61
62
62
$ classMetadataProphecy = $ this ->prophesize (ClassMetadata::class);
63
63
$ classMetadataProphecy ->getAssociationNames ()->shouldBeCalled ()->willReturn ([0 => 'relatedDummy ' , 'relatedDummy2 ' ]);
64
64
$ classMetadataProphecy ->associationMappings = [
65
- 'relatedDummy ' => ['fetch ' => 3 , 'joinColumns ' => [['nullable ' => true ]], 'targetEntity ' => DummyRelated ::class],
66
- 'relatedDummy2 ' => ['fetch ' => 3 , 'joinColumns ' => [['nullable ' => false ]], 'targetEntity ' => DummyRelated ::class],
65
+ 'relatedDummy ' => ['fetch ' => 3 , 'joinColumns ' => [['nullable ' => true ]], 'targetEntity ' => RelatedDummy ::class],
66
+ 'relatedDummy2 ' => ['fetch ' => 3 , 'joinColumns ' => [['nullable ' => false ]], 'targetEntity ' => RelatedDummy ::class],
67
67
];
68
68
69
69
$ relatedClassMetadataProphecy = $ this ->prophesize (ClassMetadata::class);
@@ -78,14 +78,14 @@ public function testApplyToCollection()
78
78
79
79
$ emProphecy = $ this ->prophesize (EntityManager::class);
80
80
$ emProphecy ->getClassMetadata (Dummy::class)->shouldBeCalled ()->willReturn ($ classMetadataProphecy ->reveal ());
81
- $ emProphecy ->getClassMetadata (DummyRelated ::class)->shouldBeCalled ()->willReturn ($ relatedClassMetadataProphecy ->reveal ());
81
+ $ emProphecy ->getClassMetadata (RelatedDummy ::class)->shouldBeCalled ()->willReturn ($ relatedClassMetadataProphecy ->reveal ());
82
82
83
83
$ queryBuilderProphecy ->leftJoin ('o.relatedDummy ' , 'a0 ' )->shouldBeCalled (1 );
84
84
$ queryBuilderProphecy ->innerJoin ('o.relatedDummy2 ' , 'a11 ' )->shouldBeCalled (1 );
85
85
$ queryBuilderProphecy ->addSelect ('partial a0.{id,name} ' )->shouldBeCalled (1 );
86
86
$ queryBuilderProphecy ->addSelect ('partial a11.{id,name} ' )->shouldBeCalled (1 );
87
87
88
- $ em = $ queryBuilderProphecy ->getEntityManager ()->shouldBeCalled (2 )->willReturn ($ emProphecy ->reveal ());
88
+ $ queryBuilderProphecy ->getEntityManager ()->shouldBeCalled (2 )->willReturn ($ emProphecy ->reveal ());
89
89
90
90
$ queryBuilder = $ queryBuilderProphecy ->reveal ();
91
91
$ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal ());
@@ -98,7 +98,7 @@ public function testApplyToItem()
98
98
99
99
$ relatedNameCollection = new PropertyNameCollection (['id ' , 'name ' , 'notindatabase ' , 'notreadable ' ]);
100
100
101
- $ propertyNameCollectionFactoryProphecy ->create (DummyRelated ::class)->willReturn ($ relatedNameCollection )->shouldBeCalled ();
101
+ $ propertyNameCollectionFactoryProphecy ->create (RelatedDummy ::class)->willReturn ($ relatedNameCollection )->shouldBeCalled ();
102
102
103
103
$ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
104
104
$ relationPropertyMetadata = new PropertyMetadata ();
@@ -118,20 +118,20 @@ public function testApplyToItem()
118
118
$ notReadablePropertyMetadata = new PropertyMetadata ();
119
119
$ notReadablePropertyMetadata = $ notReadablePropertyMetadata ->withReadable (false );
120
120
121
- $ propertyMetadataFactoryProphecy ->create (DummyRelated ::class, 'id ' )->willReturn ($ idPropertyMetadata )->shouldBeCalled ();
122
- $ propertyMetadataFactoryProphecy ->create (DummyRelated ::class, 'name ' )->willReturn ($ namePropertyMetadata )->shouldBeCalled ();
123
- $ propertyMetadataFactoryProphecy ->create (DummyRelated ::class, 'notindatabase ' )->willReturn ($ notInDatabasePropertyMetadata )->shouldBeCalled ();
124
- $ propertyMetadataFactoryProphecy ->create (DummyRelated ::class, 'notreadable ' )->willReturn ($ notReadablePropertyMetadata )->shouldBeCalled ();
121
+ $ propertyMetadataFactoryProphecy ->create (RelatedDummy ::class, 'id ' )->willReturn ($ idPropertyMetadata )->shouldBeCalled ();
122
+ $ propertyMetadataFactoryProphecy ->create (RelatedDummy ::class, 'name ' )->willReturn ($ namePropertyMetadata )->shouldBeCalled ();
123
+ $ propertyMetadataFactoryProphecy ->create (RelatedDummy ::class, 'notindatabase ' )->willReturn ($ notInDatabasePropertyMetadata )->shouldBeCalled ();
124
+ $ propertyMetadataFactoryProphecy ->create (RelatedDummy ::class, 'notreadable ' )->willReturn ($ notReadablePropertyMetadata )->shouldBeCalled ();
125
125
126
126
$ queryBuilderProphecy = $ this ->prophesize (QueryBuilder::class);
127
127
128
128
$ classMetadataProphecy = $ this ->prophesize (ClassMetadata::class);
129
129
$ classMetadataProphecy ->getAssociationNames ()->shouldBeCalled ()->willReturn ([0 => 'relatedDummy ' , 'relatedDummy2 ' , 'relatedDummy3 ' , 'relatedDummy4 ' ]);
130
130
$ classMetadataProphecy ->associationMappings = [
131
- 'relatedDummy ' => ['fetch ' => 3 , 'joinColumns ' => [['nullable ' => true ]], 'targetEntity ' => DummyRelated ::class],
132
- 'relatedDummy2 ' => ['fetch ' => 3 , 'joinColumns ' => [['nullable ' => false ]], 'targetEntity ' => DummyRelated ::class],
133
- 'relatedDummy3 ' => ['fetch ' => 3 , 'joinTable ' => ['joinColumns ' => [['nullable ' => false ]]], 'targetEntity ' => DummyRelated ::class],
134
- 'relatedDummy4 ' => ['fetch ' => 3 , 'targetEntity ' => DummyRelated ::class],
131
+ 'relatedDummy ' => ['fetch ' => 3 , 'joinColumns ' => [['nullable ' => true ]], 'targetEntity ' => RelatedDummy ::class],
132
+ 'relatedDummy2 ' => ['fetch ' => 3 , 'joinColumns ' => [['nullable ' => false ]], 'targetEntity ' => RelatedDummy ::class],
133
+ 'relatedDummy3 ' => ['fetch ' => 3 , 'joinTable ' => ['joinColumns ' => [['nullable ' => false ]]], 'targetEntity ' => RelatedDummy ::class],
134
+ 'relatedDummy4 ' => ['fetch ' => 3 , 'targetEntity ' => RelatedDummy ::class],
135
135
];
136
136
137
137
$ relatedClassMetadataProphecy = $ this ->prophesize (ClassMetadata::class);
@@ -146,7 +146,7 @@ public function testApplyToItem()
146
146
147
147
$ emProphecy = $ this ->prophesize (EntityManager::class);
148
148
$ emProphecy ->getClassMetadata (Dummy::class)->shouldBeCalled ()->willReturn ($ classMetadataProphecy ->reveal ());
149
- $ emProphecy ->getClassMetadata (DummyRelated ::class)->shouldBeCalled ()->willReturn ($ relatedClassMetadataProphecy ->reveal ());
149
+ $ emProphecy ->getClassMetadata (RelatedDummy ::class)->shouldBeCalled ()->willReturn ($ relatedClassMetadataProphecy ->reveal ());
150
150
151
151
$ queryBuilderProphecy ->leftJoin ('o.relatedDummy ' , 'a0 ' )->shouldBeCalled (1 );
152
152
$ queryBuilderProphecy ->innerJoin ('o.relatedDummy2 ' , 'a11 ' )->shouldBeCalled (1 );
@@ -157,7 +157,7 @@ public function testApplyToItem()
157
157
$ queryBuilderProphecy ->addSelect ('partial a122.{id,name} ' )->shouldBeCalled (1 );
158
158
$ queryBuilderProphecy ->addSelect ('partial a1233.{id,name} ' )->shouldBeCalled (1 );
159
159
160
- $ em = $ queryBuilderProphecy ->getEntityManager ()->shouldBeCalled (2 )->willReturn ($ emProphecy ->reveal ());
160
+ $ queryBuilderProphecy ->getEntityManager ()->shouldBeCalled (2 )->willReturn ($ emProphecy ->reveal ());
161
161
162
162
$ queryBuilder = $ queryBuilderProphecy ->reveal ();
163
163
$ orderExtensionTest = new EagerLoadingExtension ($ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal ());
0 commit comments