24
24
use ApiPlatform \Core \Tests \Fixtures \TestBundle \Entity \Dummy ;
25
25
use PHPUnit \Framework \TestCase ;
26
26
use Prophecy \Argument ;
27
+ use Symfony \Component \Serializer \NameConverter \NameConverterInterface ;
27
28
use Symfony \Component \Serializer \Normalizer \NormalizerInterface ;
28
29
use Symfony \Component \Serializer \SerializerInterface ;
29
30
@@ -41,12 +42,15 @@ public function testDonTSupportDenormalization()
41
42
$ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
42
43
$ iriConverterProphecy = $ this ->prophesize (IriConverterInterface::class);
43
44
$ resourceClassResolverProphecy = $ this ->prophesize (ResourceClassResolverInterface::class);
45
+ $ nameConverter = $ this ->prophesize (NameConverterInterface::class);
44
46
45
47
$ normalizer = new ItemNormalizer (
46
48
$ propertyNameCollectionFactoryProphecy ->reveal (),
47
49
$ propertyMetadataFactoryProphecy ->reveal (),
48
50
$ iriConverterProphecy ->reveal (),
49
- $ resourceClassResolverProphecy ->reveal ()
51
+ $ resourceClassResolverProphecy ->reveal (),
52
+ null ,
53
+ $ nameConverter ->reveal ()
50
54
);
51
55
52
56
$ this ->assertFalse ($ normalizer ->supportsDenormalization ('foo ' , ItemNormalizer::FORMAT ));
@@ -67,11 +71,15 @@ public function testSupportNormalization()
67
71
$ resourceClassResolverProphecy ->getResourceClass ($ dummy )->willReturn (Dummy::class)->shouldBeCalled ();
68
72
$ resourceClassResolverProphecy ->getResourceClass ($ std )->willThrow (new InvalidArgumentException ())->shouldBeCalled ();
69
73
74
+ $ nameConverter = $ this ->prophesize (NameConverterInterface::class);
75
+
70
76
$ normalizer = new ItemNormalizer (
71
77
$ propertyNameCollectionFactoryProphecy ->reveal (),
72
78
$ propertyMetadataFactoryProphecy ->reveal (),
73
79
$ iriConverterProphecy ->reveal (),
74
- $ resourceClassResolverProphecy ->reveal ()
80
+ $ resourceClassResolverProphecy ->reveal (),
81
+ null ,
82
+ $ nameConverter ->reveal ()
75
83
);
76
84
77
85
$ this ->assertTrue ($ normalizer ->supportsNormalization ($ dummy , 'jsonhal ' ));
@@ -103,11 +111,16 @@ public function testNormalize()
103
111
$ serializerProphecy ->willImplement (NormalizerInterface::class);
104
112
$ serializerProphecy ->normalize ('hello ' , null , Argument::type ('array ' ))->willReturn ('hello ' )->shouldBeCalled ();
105
113
114
+ $ nameConverter = $ this ->prophesize (NameConverterInterface::class);
115
+ $ nameConverter ->normalize ('name ' )->shouldBeCalled ()->willReturn ('name ' );
116
+
106
117
$ normalizer = new ItemNormalizer (
107
118
$ propertyNameCollectionFactoryProphecy ->reveal (),
108
119
$ propertyMetadataFactoryProphecy ->reveal (),
109
120
$ iriConverterProphecy ->reveal (),
110
- $ resourceClassResolverProphecy ->reveal ()
121
+ $ resourceClassResolverProphecy ->reveal (),
122
+ null ,
123
+ $ nameConverter ->reveal ()
111
124
);
112
125
$ normalizer ->setSerializer ($ serializerProphecy ->reveal ());
113
126
@@ -146,11 +159,16 @@ public function testNormalizeWithoutCache()
146
159
$ serializerProphecy ->willImplement (NormalizerInterface::class);
147
160
$ serializerProphecy ->normalize ('hello ' , null , Argument::type ('array ' ))->willReturn ('hello ' )->shouldBeCalled ();
148
161
162
+ $ nameConverter = $ this ->prophesize (NameConverterInterface::class);
163
+ $ nameConverter ->normalize ('name ' )->shouldBeCalled ()->willReturn ('name ' );
164
+
149
165
$ normalizer = new ItemNormalizer (
150
166
$ propertyNameCollectionFactoryProphecy ->reveal (),
151
167
$ propertyMetadataFactoryProphecy ->reveal (),
152
168
$ iriConverterProphecy ->reveal (),
153
- $ resourceClassResolverProphecy ->reveal ()
169
+ $ resourceClassResolverProphecy ->reveal (),
170
+ null ,
171
+ $ nameConverter ->reveal ()
154
172
);
155
173
$ normalizer ->setSerializer ($ serializerProphecy ->reveal ());
156
174
0 commit comments