Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8ae39cb

Browse filesBrowse files
committed
Test denormalization of object with variadic constructor typed argument
1 parent b4364aa commit 8ae39cb
Copy full SHA for 8ae39cb

File tree

Expand file treeCollapse file tree

2 files changed

+41
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+41
-0
lines changed
+27Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php
+14Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.