|
18 | 18 | use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
|
19 | 19 | use Symfony\Component\Serializer\Encoder\CsvEncoder;
|
20 | 20 | use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
| 21 | +use Symfony\Component\Serializer\Encoder\XmlEncoder; |
21 | 22 | use Symfony\Component\Serializer\Exception\ExtraAttributesException;
|
22 | 23 | use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
23 | 24 | use Symfony\Component\Serializer\Exception\LogicException;
|
|
56 | 57 | use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageNumberOne;
|
57 | 58 | use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageNumberThree;
|
58 | 59 | use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageNumberTwo;
|
| 60 | +use Symfony\Component\Serializer\Tests\Fixtures\DummyNullableInt; |
59 | 61 | use Symfony\Component\Serializer\Tests\Fixtures\DummyObjectWithEnumConstructor;
|
60 | 62 | use Symfony\Component\Serializer\Tests\Fixtures\DummyObjectWithEnumProperty;
|
61 | 63 | use Symfony\Component\Serializer\Tests\Fixtures\DummyWithObjectOrNull;
|
@@ -751,6 +753,16 @@ public function testDeserializeWrappedScalar()
|
751 | 753 | $this->assertSame(42, $serializer->deserialize('{"wrapper": 42}', 'int', 'json', [UnwrappingDenormalizer::UNWRAP_PATH => '[wrapper]']));
|
752 | 754 | }
|
753 | 755 |
|
| 756 | + public function testDeserializeNullableIntInXml() |
| 757 | + { |
| 758 | + $extractor = new PropertyInfoExtractor([], [new ReflectionExtractor()]); |
| 759 | + $serializer = new Serializer([new ObjectNormalizer(null, null, null, $extractor)], ['xml' => new XmlEncoder()]); |
| 760 | + |
| 761 | + $obj = $serializer->deserialize('<?xml version="1.0" encoding="UTF-8"?><DummyNullableInt><value/></DummyNullableInt>', DummyNullableInt::class, 'xml',); |
| 762 | + $this->assertInstanceOf(DummyNullableInt::class, $obj); |
| 763 | + $this->assertNull($obj->value); |
| 764 | + } |
| 765 | + |
754 | 766 | public function testUnionTypeDeserializable()
|
755 | 767 | {
|
756 | 768 | $classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
|
|
0 commit comments