public function testNormalizeTraversable() { $serializer =
new Serializer([],
['json' =>
new JsonEncoder()]);
$result =
$serializer->
serialize(new TraversableDummy(), 'json'
);
$this->
assertEquals('{"foo":"foo","bar":"bar"}',
$result);
} public function testNormalizeGivesPriorityToInterfaceOverTraversable() { $serializer =
new Serializer([new CustomNormalizer()],
['json' =>
new JsonEncoder()]);
$result =
$serializer->
serialize(new NormalizableTraversableDummy(), 'json'
);
$this->
assertEquals('{"foo":"normalizedFoo","bar":"normalizedBar"}',
$result);
} public function testNormalizeOnDenormalizer() { $this->
expectException(UnexpectedValueException::
class);
$serializer =
new Serializer([new TestDenormalizer()],
[]);
$this->
assertTrue($serializer->
normalize(new \
stdClass(), 'json'
));
} public function testDenormalizeNoMatch() {