|
20 | 20 | use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
|
21 | 21 | use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
22 | 22 | use Symfony\Component\Serializer\Mapping\Loader\LoaderChain;
|
| 23 | +use Symfony\Component\Serializer\NameConverter\NameConverterInterface; |
23 | 24 | use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
24 | 25 | use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
25 | 26 | use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
|
@@ -168,6 +169,7 @@ public function testObjectWithNullableNonOptionalConstructorArgumentWithoutInput
|
168 | 169 |
|
169 | 170 | /**
|
170 | 171 | * @dataProvider getNormalizer
|
| 172 | + * @dataProvider getNormalizerWithCustomNameConverter |
171 | 173 | */
|
172 | 174 | public function testObjectWithVariadicConstructorTypedArguments(AbstractNormalizer $normalizer)
|
173 | 175 | {
|
@@ -243,6 +245,25 @@ public static function getNormalizer()
|
243 | 245 | yield [new ObjectNormalizer(null, null, null, $extractor)];
|
244 | 246 | }
|
245 | 247 |
|
| 248 | + public static function getNormalizerWithCustomNameConverter() |
| 249 | + { |
| 250 | + $extractor = new PhpDocExtractor(); |
| 251 | + $nameConverter = new class() implements NameConverterInterface { |
| 252 | + public function normalize(string $propertyName): string |
| 253 | + { |
| 254 | + return ucfirst($propertyName); |
| 255 | + } |
| 256 | + |
| 257 | + public function denormalize(string $propertyName): string |
| 258 | + { |
| 259 | + return lcfirst($propertyName); |
| 260 | + } |
| 261 | + }; |
| 262 | + |
| 263 | + yield [new PropertyNormalizer(null, $nameConverter, $extractor)]; |
| 264 | + yield [new ObjectNormalizer(null, $nameConverter, null, $extractor)]; |
| 265 | + } |
| 266 | + |
246 | 267 | public function testIgnore()
|
247 | 268 | {
|
248 | 269 | $classMetadata = new ClassMetadata(IgnoreDummy::class);
|
|
0 commit comments