Sfoglia il codice sorgente

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

Samuel Gordalina 12 anni fa
parent
commit
56a89d77a2

+ 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 getContent($key);
     abstract protected function getFormat();
     abstract protected function getFormat();