27
27
use ApiPlatform \Core \Metadata \Resource \ResourceMetadata ;
28
28
use ApiPlatform \Core \Metadata \Resource \ResourceNameCollection ;
29
29
use ApiPlatform \Core \Operation \Factory \SubresourceOperationFactoryInterface ;
30
+ use ApiPlatform \Core \Tests \Fixtures \TestBundle \Serializer \NameConverter \CustomConverter ;
30
31
use PHPUnit \Framework \TestCase ;
31
32
use Prophecy \Argument ;
32
33
use Symfony \Component \PropertyInfo \Type ;
@@ -44,7 +45,7 @@ public function testNormalize()
44
45
$ documentation = new Documentation (new ResourceNameCollection (['dummy ' => 'dummy ' ]), $ title , $ desc , $ version , []);
45
46
46
47
$ 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 ' ]));
48
49
49
50
$ 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 ' ]], []);
50
51
$ resourceMetadataFactoryProphecy = $ this ->prophesize (ResourceMetadataFactoryInterface::class);
@@ -54,6 +55,7 @@ public function testNormalize()
54
55
$ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
55
56
$ propertyMetadataFactoryProphecy ->create ('dummy ' , 'name ' )->shouldBeCalled ()->willReturn (new PropertyMetadata (new Type (Type::BUILTIN_TYPE_STRING ), 'name ' , true , true , true , true , false , false , null , null , []));
56
57
$ 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 , []));
57
59
$ subresourceMetadata = new SubresourceMetadata ('relatedDummy ' , false );
58
60
$ 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 ));
59
61
@@ -94,7 +96,9 @@ public function testNormalize()
94
96
$ resourceClassResolverProphecy ->reveal (),
95
97
$ operationMethodResolverProphecy ->reveal (),
96
98
$ urlGenerator ->reveal (),
97
- $ subresourceOperationFactoryProphecy ->reveal ());
99
+ $ subresourceOperationFactoryProphecy ->reveal (),
100
+ new CustomConverter ()
101
+ );
98
102
99
103
$ expected = [
100
104
'@context ' => [
@@ -168,6 +172,21 @@ public function testNormalize()
168
172
'hydra:writable ' => true ,
169
173
'hydra:description ' => 'description ' ,
170
174
],
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
+ ],
171
190
[
172
191
'@type ' => 'hydra:SupportedProperty ' ,
173
192
'hydra:property ' => [
0 commit comments