|
42 | 42 | use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
43 | 43 | use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
44 | 44 | use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
| 45 | +use Symfony\Component\Serializer\Normalizer\PropertyNormalizer; |
45 | 46 | use Symfony\Component\Serializer\Serializer;
|
46 | 47 | use Symfony\Component\Serializer\SerializerAwareInterface;
|
47 | 48 | use Symfony\Component\Serializer\SerializerInterface;
|
48 | 49 | use Symfony\Component\Serializer\Tests\Fixtures\Attributes\AbstractDummy;
|
49 | 50 | use Symfony\Component\Serializer\Tests\Fixtures\Attributes\AbstractDummyFirstChild;
|
50 | 51 | use Symfony\Component\Serializer\Tests\Fixtures\Attributes\AbstractDummySecondChild;
|
51 | 52 | use Symfony\Component\Serializer\Tests\Fixtures\DummyFirstChildQuux;
|
| 53 | +use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface; |
| 54 | +use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageNumberFour; |
52 | 55 | use Symfony\Component\Serializer\Tests\Fixtures\DummySecondChildQuux;
|
53 | 56 | use Symfony\Component\Serializer\Tests\Fixtures\DummyString;
|
54 | 57 | use Symfony\Component\Serializer\Tests\Fixtures\DummyWithNotNormalizable;
|
@@ -1087,6 +1090,25 @@ public static function provideBooleanTypesData()
|
1087 | 1090 | [['foo' => false], TruePropertyDummy::class],
|
1088 | 1091 | ];
|
1089 | 1092 | }
|
| 1093 | + |
| 1094 | + public function testDeserializeAndSerializeConstructorAndIgnoreAndInterfacedObjectsWithTheClassMetadataDiscriminator() |
| 1095 | + { |
| 1096 | + $example = new DummyMessageNumberFour('Hello'); |
| 1097 | + |
| 1098 | + $classMetadataFactory = new ClassMetadataFactory(new AttributeLoader()); |
| 1099 | + |
| 1100 | + $normalizer = new PropertyNormalizer( |
| 1101 | + $classMetadataFactory, |
| 1102 | + null, |
| 1103 | + new PropertyInfoExtractor([], [new PhpDocExtractor(), new ReflectionExtractor()]), |
| 1104 | + new ClassDiscriminatorFromClassMetadata($classMetadataFactory), |
| 1105 | + ); |
| 1106 | + |
| 1107 | + $serialized = $normalizer->normalize($example, 'json'); |
| 1108 | + $deserialized = $normalizer->denormalize($serialized, DummyMessageInterface::class, 'json'); |
| 1109 | + |
| 1110 | + $this->assertEquals($example, $deserialized); |
| 1111 | + } |
1090 | 1112 | }
|
1091 | 1113 |
|
1092 | 1114 | class AbstractObjectNormalizerDummy extends AbstractObjectNormalizer
|
|
0 commit comments