public function testDeserializeInconsistentScalarArray() { $this->
expectException(NotNormalizableValueException::
class);
$serializer =
new Serializer([new ArrayDenormalizer()],
['json' =>
new JsonEncoder()]);
$serializer->
deserialize('["42"]', 'int[]', 'json'
);
} public function testDeserializeOnObjectWithObjectCollectionProperty() { $serializer =
new Serializer([new FooInterfaceDummyDenormalizer(),
new ObjectNormalizer(null, null, null,
new PhpDocExtractor())],
[new JsonEncoder()]);
$obj =
$serializer->
deserialize('{"foo":[{"name":"bar"}]}', ObjectCollectionPropertyDummy::
class, 'json'
);
$this->
assertInstanceOf(ObjectCollectionPropertyDummy::
class,
$obj);
$fooDummyObjects =
$obj->
getFoo();
$this->
assertCount(1,
$fooDummyObjects);
$fooDummyObject =
$fooDummyObjects[0
];
$this->
assertInstanceOf(FooImplementationDummy::
class,
$fooDummyObject);
$this->
assertSame('bar',
$fooDummyObject->name
);
}