|
30 | 30 | use Symfony\Component\Serializer\SerializerInterface; |
31 | 31 | use Symfony\Component\Serializer\Tests\Fixtures\Attributes\GroupDummy; |
32 | 32 | use Symfony\Component\Serializer\Tests\Fixtures\Attributes\GroupDummyChild; |
| 33 | +use Symfony\Component\Serializer\Tests\Fixtures\ChildClassDummy; |
33 | 34 | use Symfony\Component\Serializer\Tests\Fixtures\Dummy; |
34 | 35 | use Symfony\Component\Serializer\Tests\Fixtures\Php74Dummy; |
35 | 36 | use Symfony\Component\Serializer\Tests\Fixtures\PropertyCircularReferenceDummy; |
36 | 37 | use Symfony\Component\Serializer\Tests\Fixtures\PropertySiblingHolder; |
| 38 | +use Symfony\Component\Serializer\Tests\Fixtures\SpecialBookDummy; |
37 | 39 | use Symfony\Component\Serializer\Tests\Normalizer\Features\CacheableObjectAttributesTestTrait; |
38 | 40 | use Symfony\Component\Serializer\Tests\Normalizer\Features\CallbacksTestTrait; |
39 | 41 | use Symfony\Component\Serializer\Tests\Normalizer\Features\CircularReferenceTestTrait; |
@@ -176,6 +178,39 @@ public function testDenormalize() |
176 | 178 | $this->assertEquals('bar', $obj->getBar()); |
177 | 179 | } |
178 | 180 |
|
| 181 | + /** |
| 182 | + * @requires PHP 8.2 |
| 183 | + */ |
| 184 | + public function testDenormalizeWithReadOnlyClass() |
| 185 | + { |
| 186 | + /** @var ChildClassDummy $object */ |
| 187 | + $object = $this->normalizer->denormalize( |
| 188 | + ['parentProp' => 'parentProp', 'childProp' => 'childProp'], |
| 189 | + ChildClassDummy::class, |
| 190 | + 'any' |
| 191 | + ); |
| 192 | + |
| 193 | + $this->assertSame('parentProp', $object->getParentProp()); |
| 194 | + $this->assertSame('childProp', $object->childProp); |
| 195 | + } |
| 196 | + |
| 197 | + /** |
| 198 | + * @requires PHP 8.4 |
| 199 | + */ |
| 200 | + public function testDenormalizeWithAsymmetricPropertyVisibility() |
| 201 | + { |
| 202 | + /** @var SpecialBookDummy $object */ |
| 203 | + $object = $this->normalizer->denormalize( |
| 204 | + ['title' => 'life', 'author' => 'Santiago San Martin', 'pubYear' => 2000], |
| 205 | + SpecialBookDummy::class, |
| 206 | + 'any' |
| 207 | + ); |
| 208 | + |
| 209 | + $this->assertSame('life', $object->title); |
| 210 | + $this->assertSame('Santiago San Martin', $object->author); |
| 211 | + $this->assertSame(2000, $object->getPubYear()); |
| 212 | + } |
| 213 | + |
179 | 214 | public function testNormalizeWithParentClass() |
180 | 215 | { |
181 | 216 | $group = new GroupDummyChild(); |
|
0 commit comments