فهرست منبع

Add test to verify that its not possible to deserialize base polymorphic class without type

Samuel Gordalina 12 سال پیش
والد
کامیت
56a89d77a2
1فایلهای تغییر یافته به همراه16 افزوده شده و 0 حذف شده
  1. 16 0
      tests/JMS/Serializer/Tests/Serializer/BaseSerializationTest.php

+ 16 - 0
tests/JMS/Serializer/Tests/Serializer/BaseSerializationTest.php

@@ -697,6 +697,22 @@ abstract class BaseSerializationTest extends \PHPUnit_Framework_TestCase
         }
     }
 
+    /**
+     * @group polymorphic
+     * @expectedException LogicException
+     */
+    public function testPolymorphicObjectsInvalidDeserialization()
+    {
+        if (!$this->hasDeserializer()) {
+            throw new \LogicException('No deserializer');
+        }
+
+        $this->deserialize(
+            $this->getContent('car_without_type'),
+            'JMS\Serializer\Tests\Fixtures\Discriminator\Vehicle'
+        );
+    }
+
     abstract protected function getContent($key);
     abstract protected function getFormat();