@@ -186,4 +186,38 @@ public function testDenormalizeWithIdAndUpdateNotAllowed()
186
186
$ normalizer ->setSerializer ($ serializerProphecy ->reveal ());
187
187
$ normalizer ->denormalize (['id ' => '12 ' , 'name ' => 'hello ' ], Dummy::class, null , $ context );
188
188
}
189
+
190
+ public function testDenormalizeWithIdAndNoResourceClass ()
191
+ {
192
+ $ context = [];
193
+
194
+ $ propertyNameCollection = new PropertyNameCollection (['id ' , 'name ' ]);
195
+ $ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
196
+ $ propertyNameCollectionFactoryProphecy ->create (Dummy::class, [])->willReturn ($ propertyNameCollection )->shouldBeCalled ();
197
+
198
+ $ propertyMetadataFactory = new PropertyMetadata (null , null , true , true );
199
+ $ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
200
+ $ propertyMetadataFactoryProphecy ->create (Dummy::class, 'id ' , [])->willReturn ($ propertyMetadataFactory )->shouldBeCalled ();
201
+ $ propertyMetadataFactoryProphecy ->create (Dummy::class, 'name ' , [])->willReturn ($ propertyMetadataFactory )->shouldBeCalled ();
202
+
203
+ $ iriConverterProphecy = $ this ->prophesize (IriConverterInterface::class);
204
+
205
+ $ resourceClassResolverProphecy = $ this ->prophesize (ResourceClassResolverInterface::class);
206
+
207
+ $ serializerProphecy = $ this ->prophesize (SerializerInterface::class);
208
+ $ serializerProphecy ->willImplement (DenormalizerInterface::class);
209
+
210
+ $ normalizer = new ItemNormalizer (
211
+ $ propertyNameCollectionFactoryProphecy ->reveal (),
212
+ $ propertyMetadataFactoryProphecy ->reveal (),
213
+ $ iriConverterProphecy ->reveal (),
214
+ $ resourceClassResolverProphecy ->reveal ()
215
+ );
216
+ $ normalizer ->setSerializer ($ serializerProphecy ->reveal ());
217
+
218
+ $ object = $ normalizer ->denormalize (['id ' => '42 ' , 'name ' => 'hello ' ], Dummy::class, null , $ context );
219
+ $ this ->assertInstanceOf (Dummy::class, $ object );
220
+ $ this ->assertSame ('42 ' , $ object ->getId ());
221
+ $ this ->assertSame ('hello ' , $ object ->getName ());
222
+ }
189
223
}
0 commit comments