@@ -125,6 +125,39 @@ public function testDenormalize()
125
125
$ this ->assertInstanceOf (Dummy::class, $ normalizer ->denormalize (['name ' => 'hello ' ], Dummy::class, null , $ context ));
126
126
}
127
127
128
+
129
+ public function testDenormalizeWithIri ()
130
+ {
131
+ $ context = ['resource_class ' => Dummy::class, 'api_allow_update ' => true ];
132
+
133
+ $ propertyNameCollection = new PropertyNameCollection (['name ' ]);
134
+ $ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
135
+ $ propertyNameCollectionFactoryProphecy ->create (Dummy::class, [])->willReturn ($ propertyNameCollection )->shouldBeCalled ();
136
+
137
+ $ propertyMetadataFactory = new PropertyMetadata (null , null , true );
138
+ $ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
139
+ $ propertyMetadataFactoryProphecy ->create (Dummy::class, 'name ' , [])->willReturn ($ propertyMetadataFactory )->shouldBeCalled ();
140
+
141
+ $ iriConverterProphecy = $ this ->prophesize (IriConverterInterface::class);
142
+ $ iriConverterProphecy ->getItemFromIri ("/dummies/12 " , ["resource_class " => Dummy::class, 'api_allow_update ' => true , "fetch_data " => false ])->shouldBeCalled ();
143
+
144
+ $ resourceClassResolverProphecy = $ this ->prophesize (ResourceClassResolverInterface::class);
145
+
146
+ $ serializerProphecy = $ this ->prophesize (SerializerInterface::class);
147
+ $ serializerProphecy ->willImplement (DenormalizerInterface::class);
148
+
149
+ $ normalizer = new ItemNormalizer (
150
+ $ propertyNameCollectionFactoryProphecy ->reveal (),
151
+ $ propertyMetadataFactoryProphecy ->reveal (),
152
+ $ iriConverterProphecy ->reveal (),
153
+ $ resourceClassResolverProphecy ->reveal ()
154
+ );
155
+ $ normalizer ->setSerializer ($ serializerProphecy ->reveal ());
156
+
157
+ $ this ->assertInstanceOf (Dummy::class, $ normalizer ->denormalize (['@id ' => '/dummies/12 ' , 'id ' => '12 ' , 'name ' => 'hello ' ], Dummy::class, null , $ context ));
158
+ }
159
+
160
+
128
161
/**
129
162
* @expectedException \ApiPlatform\Core\Exception\InvalidArgumentException
130
163
* @expectedExceptionMessage Update is not allowed for this operation.
@@ -151,6 +184,6 @@ public function testDenormalizeWithIdAndUpdateNotAllowed()
151
184
$ resourceClassResolverProphecy ->reveal ()
152
185
);
153
186
$ normalizer ->setSerializer ($ serializerProphecy ->reveal ());
154
- $ normalizer ->denormalize (['id ' => '/dummies/12 ' , 'name ' => 'hello ' ], Dummy::class, null , $ context );
187
+ $ normalizer ->denormalize (['@ id ' => '/dummies/12 ' , ' id ' => ' 12 ' , 'name ' => 'hello ' ], Dummy::class, null , $ context );
155
188
}
156
189
}
0 commit comments