Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / serializer / Tests / Normalizer / AbstractNormalizerTest.php
index bad7d3432176d073ea65f6a794be284cb16ac89c..28edc05872710aed8c84cd555f5492cb423e7258 100644 (file)
@@ -9,7 +9,10 @@ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
 use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
 use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
 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;
 
 /**
  * Provides a dummy Normalizer which extends the AbstractNormalizer.
@@ -104,4 +107,25 @@ class AbstractNormalizerTest extends TestCase
 
         $this->assertSame('bar', $proxyDummy->getFoo());
     }
+
+    public function testObjectWithStaticConstructor()
+    {
+        $normalizer = new StaticConstructorNormalizer();
+        $dummy = $normalizer->denormalize(array('foo' => 'baz'), StaticConstructorDummy::class);
+
+        $this->assertInstanceOf(StaticConstructorDummy::class, $dummy);
+        $this->assertEquals('baz', $dummy->quz);
+        $this->assertNull($dummy->foo);
+    }
+
+    /**
+     * @requires PHP 7.1
+     */
+    public function testObjectWithNullableConstructorArgument()
+    {
+        $normalizer = new ObjectNormalizer();
+        $dummy = $normalizer->denormalize(array('foo' => null), NullableConstructorArgumentDummy::class);
+
+        $this->assertNull($dummy->getFoo());
+    }
 }