@@ -146,6 +146,7 @@ public function testPublishUpdate(): void
146
146
$ toDelete ->setId (3 );
147
147
$ toDeleteExpressionLanguage = new DummyFriend ();
148
148
$ toDeleteExpressionLanguage ->setId (4 );
149
+ $ toDeleteMercureOptions = new DummyOffer ();
149
150
150
151
$ resourceClassResolverProphecy = $ this ->prophesize (ResourceClassResolverInterface::class);
151
152
$ resourceClassResolverProphecy ->getResourceClass (Argument::type (Dummy::class))->willReturn (Dummy::class);
@@ -167,12 +168,14 @@ public function testPublishUpdate(): void
167
168
$ iriConverterProphecy ->getIriFromItem ($ toDelete )->willReturn ('/dummies/3 ' )->shouldBeCalled ();
168
169
$ iriConverterProphecy ->getIriFromItem ($ toDeleteExpressionLanguage )->willReturn ('/dummy_friends/4 ' )->shouldBeCalled ();
169
170
$ iriConverterProphecy ->getIriFromItem ($ toDeleteExpressionLanguage , UrlGeneratorInterface::ABS_URL )->willReturn ('http://example.com/dummy_friends/4 ' )->shouldBeCalled ();
171
+ $ iriConverterProphecy ->getIriFromItem ($ toDeleteMercureOptions )->willReturn ('/dummy_offers/5 ' )->shouldBeCalled ();
172
+ $ iriConverterProphecy ->getIriFromItem ($ toDeleteMercureOptions , UrlGeneratorInterface::ABS_URL )->willReturn ('http://example.com/dummy_offers/5 ' )->shouldBeCalled ();
170
173
171
174
$ resourceMetadataFactoryProphecy = $ this ->prophesize (ResourceMetadataFactoryInterface::class);
172
175
$ resourceMetadataFactoryProphecy ->create (Dummy::class)->willReturn (new ResourceMetadata (null , null , null , null , null , ['mercure ' => true , 'normalization_context ' => ['groups ' => ['foo ' , 'bar ' ]]]));
173
176
$ resourceMetadataFactoryProphecy ->create (DummyCar::class)->willReturn (new ResourceMetadata ());
174
177
$ resourceMetadataFactoryProphecy ->create (DummyFriend::class)->willReturn (new ResourceMetadata (null , null , null , null , null , ['mercure ' => ['private ' => true , 'retry ' => 10 ]]));
175
- $ resourceMetadataFactoryProphecy ->create (DummyOffer::class)->willReturn (new ResourceMetadata (null , null , null , null , null , ['mercure ' => ['topics ' => 'http://example.com/custom_topics/1 ' , 'normalization_context ' => ['groups ' => ['baz ' ]]]]));
178
+ $ resourceMetadataFactoryProphecy ->create (DummyOffer::class)->willReturn (new ResourceMetadata (null , null , null , null , null , ['mercure ' => ['topics ' => 'http://example.com/custom_topics/1 ' , 'data ' => ' mercure_custom_data ' , ' normalization_context ' => ['groups ' => ['baz ' ]]]]));
176
179
$ resourceMetadataFactoryProphecy ->create (DummyMercure::class)->willReturn (new ResourceMetadata (null , null , null , null , null , ['mercure ' => ['topics ' => ['/dummies/1 ' , '/users/3 ' ], 'normalization_context ' => ['groups ' => ['baz ' ]]]]));
177
180
178
181
$ serializerProphecy = $ this ->prophesize (SerializerInterface::class);
@@ -186,10 +189,12 @@ public function testPublishUpdate(): void
186
189
$ topics = [];
187
190
$ private = [];
188
191
$ retry = [];
189
- $ publisher = function (Update $ update ) use (&$ topics , &$ private , &$ retry ): string {
192
+ $ data = [];
193
+ $ publisher = function (Update $ update ) use (&$ topics , &$ private , &$ retry , &$ data ): string {
190
194
$ topics = array_merge ($ topics , $ update ->getTopics ());
191
195
$ private [] = $ update ->isPrivate ();
192
196
$ retry [] = $ update ->getRetry ();
197
+ $ data [] = $ update ->getData ();
193
198
194
199
return 'id ' ;
195
200
};
@@ -207,7 +212,7 @@ public function testPublishUpdate(): void
207
212
$ uowProphecy = $ this ->prophesize (UnitOfWork::class);
208
213
$ uowProphecy ->getScheduledEntityInsertions ()->willReturn ([$ toInsert , $ toInsertNotResource ])->shouldBeCalled ();
209
214
$ uowProphecy ->getScheduledEntityUpdates ()->willReturn ([$ toUpdate , $ toUpdateNoMercureAttribute , $ toUpdateMercureOptions , $ toUpdateMercureTopicOptions ])->shouldBeCalled ();
210
- $ uowProphecy ->getScheduledEntityDeletions ()->willReturn ([$ toDelete , $ toDeleteExpressionLanguage ])->shouldBeCalled ();
215
+ $ uowProphecy ->getScheduledEntityDeletions ()->willReturn ([$ toDelete , $ toDeleteExpressionLanguage, $ toDeleteMercureOptions ])->shouldBeCalled ();
211
216
212
217
$ emProphecy = $ this ->prophesize (EntityManagerInterface::class);
213
218
$ emProphecy ->getUnitOfWork ()->willReturn ($ uowProphecy ->reveal ())->shouldBeCalled ();
@@ -216,9 +221,10 @@ public function testPublishUpdate(): void
216
221
$ listener ->onFlush ($ eventArgs );
217
222
$ listener ->postFlush ();
218
223
219
- $ this ->assertSame (['http://example.com/dummies/1 ' , 'http://example.com/dummies/2 ' , 'http://example.com/custom_topics/1 ' , '/dummies/1 ' , '/users/3 ' , 'http://example.com/dummies/3 ' , 'http://example.com/dummy_friends/4 ' ], $ topics );
220
- $ this ->assertSame ([false , false , false , false , false , true ], $ private );
221
- $ this ->assertSame ([null , null , null , null , null , 10 ], $ retry );
224
+ $ this ->assertSame (['1 ' , '2 ' , 'mercure_custom_data ' , 'mercure_options ' , '{"@id":"\/dummies\/3"} ' , '{"@id":"\/dummy_friends\/4"} ' , '{"@id":"\/dummy_offers\/5"} ' ], $ data );
225
+ $ this ->assertSame (['http://example.com/dummies/1 ' , 'http://example.com/dummies/2 ' , 'http://example.com/custom_topics/1 ' , '/dummies/1 ' , '/users/3 ' , 'http://example.com/dummies/3 ' , 'http://example.com/dummy_friends/4 ' , 'http://example.com/custom_topics/1 ' ], $ topics );
226
+ $ this ->assertSame ([false , false , false , false , false , true , false ], $ private );
227
+ $ this ->assertSame ([null , null , null , null , null , 10 , null ], $ retry );
222
228
}
223
229
224
230
public function testPublishGraphQlUpdates (): void
0 commit comments