|
50 | 50 | use Symfony\Component\Serializer\Tests\Normalizer\Features\ObjectToPopulateTestTrait;
|
51 | 51 | use Symfony\Component\Serializer\Tests\Normalizer\Features\SkipNullValuesTestTrait;
|
52 | 52 | use Symfony\Component\Serializer\Tests\Normalizer\Features\TypeEnforcementTestTrait;
|
| 53 | +use Symfony\Component\Serializer\Tests\Php80Dummy; |
53 | 54 |
|
54 | 55 | /**
|
55 | 56 | * @author Kévin Dunglas <dunglas@gmail.com>
|
@@ -699,6 +700,25 @@ public function testExtractAttributesRespectsContext()
|
699 | 700 | $this->assertSame(['foo' => 'bar', 'bar' => 'foo'], $normalizer->normalize($data, null, ['include_foo_and_bar' => true]));
|
700 | 701 | }
|
701 | 702 |
|
| 703 | + /** |
| 704 | + * @requires PHP 8 |
| 705 | + */ |
| 706 | + public function testDenormalizeFalsePseudoType() |
| 707 | + { |
| 708 | + // given a serializer that extracts the attribute types of an object via ReflectionExtractor |
| 709 | + $propertyTypeExtractor = new PropertyInfoExtractor([], [new ReflectionExtractor()], [], [], []); |
| 710 | + $objectNormalizer = new ObjectNormalizer(null, null, null, $propertyTypeExtractor); |
| 711 | + |
| 712 | + $serializer = new Serializer([$objectNormalizer]); |
| 713 | + |
| 714 | + // when denormalizing some data into an object where an attribute uses the false pseudo type |
| 715 | + /** @var Php80Dummy $object */ |
| 716 | + $object = $serializer->denormalize(['canBeFalseOrString' => false], Php80Dummy::class); |
| 717 | + |
| 718 | + // then the attribute that declared false was filled correctly |
| 719 | + $this->assertFalse($object->canBeFalseOrString); |
| 720 | + } |
| 721 | + |
702 | 722 | public function testAdvancedNameConverter()
|
703 | 723 | {
|
704 | 724 | $nameConverter = new class() implements AdvancedNameConverterInterface {
|
|
0 commit comments