|
8 | 8 | use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
9 | 9 | use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
10 | 10 | use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
| 11 | +use Symfony\Component\Serializer\Normalizer\PropertyNormalizer; |
| 12 | +use Symfony\Component\Serializer\Serializer; |
11 | 13 | use Symfony\Component\Serializer\Tests\Fixtures\AbstractNormalizerDummy;
|
| 14 | +use Symfony\Component\Serializer\Tests\Fixtures\Dummy; |
12 | 15 | use Symfony\Component\Serializer\Tests\Fixtures\NullableConstructorArgumentDummy;
|
13 | 16 | use Symfony\Component\Serializer\Tests\Fixtures\ProxyDummy;
|
14 | 17 | use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorDummy;
|
15 | 18 | use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorNormalizer;
|
| 19 | +use Symfony\Component\Serializer\Tests\Fixtures\VariadicConstructorTypedArgsDummy; |
16 | 20 |
|
17 | 21 | /**
|
18 | 22 | * Provides a dummy Normalizer which extends the AbstractNormalizer.
|
@@ -128,4 +132,21 @@ public function testObjectWithNullableConstructorArgument()
|
128 | 132 |
|
129 | 133 | $this->assertNull($dummy->getFoo());
|
130 | 134 | }
|
| 135 | + |
| 136 | + /** |
| 137 | + * @requires PHP 5.6 |
| 138 | + */ |
| 139 | + public function testObjectWithVariadicConstructorTypedArguments() |
| 140 | + { |
| 141 | + $normalizer = new PropertyNormalizer(); |
| 142 | + $normalizer->setSerializer(new Serializer([$normalizer])); |
| 143 | + $data = ['foo' => [['foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz', 'qux' => 'Qux'], ['foo' => 'FOO', 'bar' => 'BAR', 'baz' => 'BAZ', 'qux' => 'QUX']]]; |
| 144 | + $dummy = $normalizer->denormalize($data, VariadicConstructorTypedArgsDummy::class); |
| 145 | + |
| 146 | + $this->assertInstanceOf(VariadicConstructorTypedArgsDummy::class, $dummy); |
| 147 | + $this->assertCount(2, $dummy->getFoo()); |
| 148 | + foreach ($dummy->getFoo() as $foo) { |
| 149 | + $this->assertInstanceOf(Dummy::class, $foo); |
| 150 | + } |
| 151 | + } |
131 | 152 | }
|
0 commit comments