/** * @expectedException \Symfony\Component\Serializer\Exception\LogicException * @expectedExceptionMessage Cannot normalize attribute "object" because injected serializer is not a normalizer */ public function testUnableToNormalizeObjectAttribute() { $serializer = $this->getMock('Symfony\\Component\\Serializer\\SerializerInterface'); $this->normalizer->setSerializer($serializer); $obj = new ObjectDummy(); $object = new \stdClass(); $obj->setObject($object); $this->normalizer->normalize($obj, 'any'); }
public function testExtractAttributesRespectsContext() { $normalizer = new FormatAndContextAwareNormalizer(); $data = new ObjectDummy(); $data->setFoo('bar'); $data->bar = 'foo'; $this->assertSame(array('foo' => 'bar', 'bar' => 'foo'), $normalizer->normalize($data, null, array('include_foo_and_bar' => true))); }