浏览代码

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();