8000 Test denormalization of object with variadic constructor typed argument · symfony/symfony@8ae39cb · GitHub
[go: up one dir, main page]

Skip to content

Commit 8ae39cb

Browse files
committed
Test denormalization of object with variadic constructor typed argument
1 parent b4364aa commit 8ae39cb

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Serializer\Tests\Fixtures;
13+
14+
class VariadicConstructorTypedArgsDummy
15+
{
16+
private $foo;
17+
18+
public function __construct(NullableConstructorArgumentDummy ...$foo)
19+
{
20+
$this->foo = $foo;
21+
}
22+
23+
public function getFoo()
24+
{
25+
return $this->foo;
26+
}
27+
}

src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
99
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
1010
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
11+
use Symfony\Component\Serializer\Serializer;
1112
use Symfony\Component\Serializer\Tests\Fixtures\AbstractNormalizerDummy;
1213
use Symfony\Component\Serializer\Tests\Fixtures\NullableConstructorArgumentDummy;
1314
use Symfony\Component\Serializer\Tests\Fixtures\ProxyDummy;
1415
use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorDummy;
1516
use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorNormalizer;
17+
use Symfony\Component\Serializer\Tests\Fixtures\VariadicConstructorTypedArgsDummy;
1618

1719
/**
1820
* Provides a dummy Normalizer which extends the AbstractNormalizer.
@@ -128,4 +130,16 @@ public function testObjectWithNullableConstructorArgument()
128130

129131
$this->assertNull($dummy->getFoo());
130132
}
133+
134+
/**
135+
* @requires PHP 7.1
136+
*/
137+
public function testObjectWithVariadicConstructorTypedArguments()
138+
{
139+
$normalizer = new ObjectNormalizer();
140+
$normalizer->setSerializer(new Serializer([$normalizer]));
141+
$dummy = $normalizer->denormalize(['foo' => [['foo' => null], ['foo' => null]]], VariadicConstructorTypedArgsDummy::class);
142+
143+
$this->assertInstanceOf(VariadicConstructorTypedArgsDummy::class, $dummy);
144+
}
131145
}

0 commit comments

Comments
 (0)
0