Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / serializer / Tests / Normalizer / GetSetMethodNormalizerTest.php
index ee0a159f06f8a3c7e372b6dfd9c9d25b943b3de0..6358cd7a908e9c36d1daf715ed3326a5058f7a57 100644 (file)
@@ -497,6 +497,23 @@ class GetSetMethodNormalizerTest extends TestCase
         $this->assertEquals('bar', $obj->getFoo());
     }
 
+    public function testHasGetterDenormalize()
+    {
+        $obj = $this->normalizer->denormalize(array('foo' => true), ObjectWithHasGetterDummy::class);
+        $this->assertTrue($obj->hasFoo());
+    }
+
+    public function testHasGetterNormalize()
+    {
+        $obj = new ObjectWithHasGetterDummy();
+        $obj->setFoo(true);
+
+        $this->assertEquals(
+            array('foo' => true),
+            $this->normalizer->normalize($obj, 'any')
+        );
+    }
+
     public function testMaxDepth()
     {
         $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
@@ -807,3 +824,18 @@ class ObjectWithJustStaticSetterDummy
         self::$foo = $foo;
     }
 }
+
+class ObjectWithHasGetterDummy
+{
+    private $foo;
+
+    public function setFoo($foo)
+    {
+        $this->foo = $foo;
+    }
+
+    public function hasFoo()
+    {
+        return $this->foo;
+    }
+}