26
26
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \Dummy ;
27
27
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \DummyCar ;
28
28
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \DummyFriend ;
29
+ use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \DummyOffer ;
29
30
use ApiPlatform \Core \Tests \ProphecyTrait ;
30
31
use Doctrine \ORM \EntityManagerInterface ;
31
32
use Doctrine \ORM \Event \OnFlushEventArgs ;
@@ -137,6 +138,7 @@ public function testPublishUpdate(): void
137
138
$ toUpdate = new Dummy ();
138
139
$ toUpdate ->setId (2 );
139
140
$ toUpdateNoMercureAttribute = new DummyCar ();
141
+ $ toUpdateMercureOptions = new DummyOffer ();
140
142
141
143
$ toDelete = new Dummy ();
142
144
$ toDelete ->setId (3 );
@@ -147,10 +149,12 @@ public function testPublishUpdate(): void
147
149
$ resourceClassResolverProphecy ->getResourceClass (Argument::type (Dummy::class))->willReturn (Dummy::class);
148
150
$ resourceClassResolverProphecy ->getResourceClass (Argument::type (DummyCar::class))->willReturn (DummyCar::class);
149
151
$ resourceClassResolverProphecy ->getResourceClass (Argument::type (DummyFriend::class))->willReturn (DummyFriend::class);
152
+ $ resourceClassResolverProphecy ->getResourceClass (Argument::type (DummyOffer::class))->willReturn (DummyOffer::class);
150
153
$ resourceClassResolverProphecy ->isResourceClass (Dummy::class)->willReturn (true );
151
154
$ resourceClassResolverProphecy ->isResourceClass (NotAResource::class)->willReturn (false );
152
155
$ resourceClassResolverProphecy ->isResourceClass (DummyCar::class)->willReturn (true );
153
156
$ resourceClassResolverProphecy ->isResourceClass (DummyFriend::class)->willReturn (true );
157
+ $ resourceClassResolverProphecy ->isResourceClass (DummyOffer::class)->willReturn (true );
154
158
155
159
$ iriConverterProphecy = $ this ->prophesize (IriConverterInterface::class);
156
160
$ iriConverterProphecy ->getIriFromItem ($ toInsert , UrlGeneratorInterface::ABS_URL )->willReturn ('http://example.com/dummies/1 ' )->shouldBeCalled ();
@@ -164,10 +168,12 @@ public function testPublishUpdate(): void
164
168
$ resourceMetadataFactoryProphecy ->create (Dummy::class)->willReturn (new ResourceMetadata (null , null , null , null , null , ['mercure ' => true , 'normalization_context ' => ['groups ' => ['foo ' , 'bar ' ]]]));
165
169
$ resourceMetadataFactoryProphecy ->create (DummyCar::class)->willReturn (new ResourceMetadata ());
166
170
$ resourceMetadataFactoryProphecy ->create (DummyFriend::class)->willReturn (new ResourceMetadata (null , null , null , null , null , ['mercure ' => ['private ' => true , 'retry ' => 10 ]]));
171
+ $ resourceMetadataFactoryProphecy ->create (DummyOffer::class)->willReturn (new ResourceMetadata (null , null , null , null , null , ['mercure ' => ['topics ' => 'http://example.com/custom_topics/1 ' , 'normalization_context ' => ['groups ' => ['baz ' ]]]]));
167
172
168
173
$ serializerProphecy = $ this ->prophesize (SerializerInterface::class);
169
174
$ serializerProphecy ->serialize ($ toInsert , 'jsonld ' , ['groups ' => ['foo ' , 'bar ' ]])->willReturn ('1 ' );
170
175
$ serializerProphecy ->serialize ($ toUpdate , 'jsonld ' , ['groups ' => ['foo ' , 'bar ' ]])->willReturn ('2 ' );
176
+ $ serializerProphecy ->serialize ($ toUpdateMercureOptions , 'jsonld ' , ['groups ' => ['baz ' ]])->willReturn ('mercure_options ' );
171
177
172
178
$ formats = ['jsonld ' => ['application/ld+json ' ], 'jsonhal ' => ['application/hal+json ' ]];
173
179
@@ -194,7 +200,7 @@ public function testPublishUpdate(): void
194
200
195
201
$ uowProphecy = $ this ->prophesize (UnitOfWork::class);
196
202
$ uowProphecy ->getScheduledEntityInsertions ()->willReturn ([$ toInsert , $ toInsertNotResource ])->shouldBeCalled ();
197
- $ uowProphecy ->getScheduledEntityUpdates ()->willReturn ([$ toUpdate , $ toUpdateNoMercureAttribute ])->shouldBeCalled ();
203
+ $ uowProphecy ->getScheduledEntityUpdates ()->willReturn ([$ toUpdate , $ toUpdateNoMercureAttribute, $ toUpdateMercureOptions ])->shouldBeCalled ();
198
204
$ uowProphecy ->getScheduledEntityDeletions ()->willReturn ([$ toDelete , $ toDeleteExpressionLanguage ])->shouldBeCalled ();
199
205
200
206
$ emProphecy = $ this ->prophesize (EntityManagerInterface::class);
@@ -204,9 +210,9 @@ public function testPublishUpdate(): void
204
210
$ listener ->onFlush ($ eventArgs );
205
211
$ listener ->postFlush ();
206
212
207
- $ this ->assertSame (['http://example.com/dummies/1 ' , 'http://example.com/dummies/2 ' , 'http://example.com/dummies/3 ' , 'http://example.com/dummy_friends/4 ' ], $ topics );
208
- $ this ->assertSame ([false , false , false , true ], $ private );
209
- $ this ->assertSame ([null , null , null , 10 ], $ retry );
213
+ $ this ->assertSame (['http://example.com/dummies/1 ' , 'http://example.com/dummies/2 ' , 'http://example.com/custom_topics/1 ' , ' http://example.com/ dummies/3 ' , 'http://example.com/dummy_friends/4 ' ], $ topics );
214
+ $ this ->assertSame ([false , false , false , false , true ], $ private );
215
+ $ this ->assertSame ([null , null , null , null , 10 ], $ retry );
210
216
}
211
217
212
218
public function testPublishGraphQlUpdates (): void
0 commit comments