Skip to content

Commit

Permalink
Test denormalization of object with variadic constructor typed argument
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgarlag committed May 9, 2019
1 parent b4364aa commit 8ae39cb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
@@ -0,0 +1,27 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Serializer\Tests\Fixtures;

class VariadicConstructorTypedArgsDummy
{
private $foo;

public function __construct(NullableConstructorArgumentDummy ...$foo)
{
$this->foo = $foo;
}

public function getFoo()
{
return $this->foo;
}
}
Expand Up @@ -8,11 +8,13 @@
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Tests\Fixtures\AbstractNormalizerDummy;
use Symfony\Component\Serializer\Tests\Fixtures\NullableConstructorArgumentDummy;
use Symfony\Component\Serializer\Tests\Fixtures\ProxyDummy;
use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorDummy;
use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorNormalizer;
use Symfony\Component\Serializer\Tests\Fixtures\VariadicConstructorTypedArgsDummy;

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

$this->assertNull($dummy->getFoo());
}

/**
* @requires PHP 7.1
*/
public function testObjectWithVariadicConstructorTypedArguments()
{
$normalizer = new ObjectNormalizer();
$normalizer->setSerializer(new Serializer([$normalizer]));
$dummy = $normalizer->denormalize(['foo' => [['foo' => null], ['foo' => null]]], VariadicConstructorTypedArgsDummy::class);

$this->assertInstanceOf(VariadicConstructorTypedArgsDummy::class, $dummy);
}
}

0 comments on commit 8ae39cb

Please sign in to comment.