2727use ApiPlatform \Core \Metadata \Resource \ResourceMetadata ;
2828use ApiPlatform \Core \Metadata \Resource \ResourceNameCollection ;
2929use ApiPlatform \Core \Operation \Factory \SubresourceOperationFactoryInterface ;
30+ use ApiPlatform \Core \Tests \Fixtures \TestBundle \Serializer \NameConverter \CustomConverter ;
3031use PHPUnit \Framework \TestCase ;
3132use Prophecy \Argument ;
3233use Symfony \Component \PropertyInfo \Type ;
@@ -44,7 +45,7 @@ public function testNormalize()
4445 $ documentation = new Documentation (new ResourceNameCollection (['dummy ' => 'dummy ' ]), $ title , $ desc , $ version , []);
4546
4647 $ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
47- $ propertyNameCollectionFactoryProphecy ->create ('dummy ' , [])->shouldBeCalled ()->willReturn (new PropertyNameCollection (['name ' , 'description ' , 'relatedDummy ' ]));
48+ $ propertyNameCollectionFactoryProphecy ->create ('dummy ' , [])->shouldBeCalled ()->willReturn (new PropertyNameCollection (['name ' , 'description ' , 'nameConverted ' , ' relatedDummy ' ]));
4849
4950 $ dummyMetadata = new ResourceMetadata ('dummy ' , 'dummy ' , '#dummy ' , ['get ' => ['method ' => 'GET ' , 'hydra_context ' => ['hydra:foo ' => 'bar ' , 'hydra:title ' => 'foobar ' ]], 'put ' => ['method ' => 'PUT ' ]], ['get ' => ['method ' => 'GET ' ], 'post ' => ['method ' => 'POST ' ]], []);
5051 $ resourceMetadataFactoryProphecy = $ this ->prophesize (ResourceMetadataFactoryInterface::class);
@@ -54,6 +55,7 @@ public function testNormalize()
5455 $ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
5556 $ propertyMetadataFactoryProphecy ->create ('dummy ' , 'name ' )->shouldBeCalled ()->willReturn (new PropertyMetadata (new Type (Type::BUILTIN_TYPE_STRING ), 'name ' , true , true , true , true , false , false , null , null , []));
5657 $ propertyMetadataFactoryProphecy ->create ('dummy ' , 'description ' )->shouldBeCalled ()->willReturn (new PropertyMetadata (new Type (Type::BUILTIN_TYPE_STRING ), 'description ' , true , true , true , true , false , false , null , null , ['jsonld_context ' => ['@type ' => '@id ' ]]));
58+ $ propertyMetadataFactoryProphecy ->create ('dummy ' , 'nameConverted ' )->shouldBeCalled ()->willReturn (new PropertyMetadata (new Type (Type::BUILTIN_TYPE_STRING ), 'name converted ' , true , true , true , true , false , false , null , null , []));
5759 $ subresourceMetadata = new SubresourceMetadata ('relatedDummy ' , false );
5860 $ propertyMetadataFactoryProphecy ->create ('dummy ' , 'relatedDummy ' )->shouldBeCalled ()->willReturn (new PropertyMetadata (new Type (Type::BUILTIN_TYPE_OBJECT , false , 'dummy ' , true , null , new Type (Type::BUILTIN_TYPE_OBJECT , false , 'relatedDummy ' )), 'This is a name. ' , true , true , true , true , false , false , null , null , [], $ subresourceMetadata ));
5961
@@ -94,7 +96,9 @@ public function testNormalize()
9496 $ resourceClassResolverProphecy ->reveal (),
9597 $ operationMethodResolverProphecy ->reveal (),
9698 $ urlGenerator ->reveal (),
97- $ subresourceOperationFactoryProphecy ->reveal ());
99+ $ subresourceOperationFactoryProphecy ->reveal (),
100+ new CustomConverter ()
101+ );
98102
99103 $ expected = [
100104 '@context ' => [
@@ -168,6 +172,21 @@ public function testNormalize()
168172 'hydra:writable ' => true ,
169173 'hydra:description ' => 'description ' ,
170174 ],
175+ [
176+ '@type ' => 'hydra:SupportedProperty ' ,
177+ 'hydra:property ' => [
178+ '@id ' => '#dummy/name_converted ' ,
179+ '@type ' => 'rdf:Property ' ,
180+ 'rdfs:label ' => 'name_converted ' ,
181+ 'domain ' => '#dummy ' ,
182+ 'range ' => 'xmls:string ' ,
183+ ],
184+ 'hydra:title ' => 'name_converted ' ,
185+ 'hydra:required ' => false ,
186+ 'hydra:readable ' => true ,
187+ 'hydra:writable ' => true ,
188+ 'hydra:description ' => 'name converted ' ,
189+ ],
171190 [
172191 '@type ' => 'hydra:SupportedProperty ' ,
173192 'hydra:property ' => [
0 commit comments