|
@@ -685,7 +685,32 @@ abstract class BaseSerializationTest extends \PHPUnit_Framework_TestCase
|
|
|
),
|
|
|
'Class is resolved correctly when least supertype is used.'
|
|
|
);
|
|
|
+
|
|
|
+ $this->assertEquals(
|
|
|
+ new Car(5),
|
|
|
+ $this->deserialize(
|
|
|
+ $this->getContent('car_without_type'),
|
|
|
+ 'JMS\Serializer\Tests\Fixtures\Discriminator\Car'
|
|
|
+ ),
|
|
|
+ 'Class is resolved correctly when concrete sub-class is used and no type is defined.'
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @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);
|