/**
  * @expectedException \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 GetSetDummy();
     $object = new \stdClass();
     $obj->setObject($object);
     $this->normalizer->normalize($obj, 'any');
 }
 public function testCircularReferenceHandler()
 {
     $serializer = new Serializer(array($this->normalizer));
     $this->normalizer->setSerializer($serializer);
     $this->normalizer->setCircularReferenceHandler(function ($obj) {
         return get_class($obj);
     });
     $obj = new CircularReferenceDummy();
     $expected = array('me' => 'Symfony\\Component\\Serializer\\Tests\\Fixtures\\CircularReferenceDummy');
     $this->assertEquals($expected, $this->normalizer->normalize($obj));
 }
 public function testMaxDepth()
 {
     $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
     $this->normalizer = new GetSetMethodNormalizer($classMetadataFactory);
     $serializer = new Serializer(array($this->normalizer));
     $this->normalizer->setSerializer($serializer);
     $level1 = new MaxDepthDummy();
     $level1->bar = 'level1';
     $level2 = new MaxDepthDummy();
     $level2->bar = 'level2';
     $level1->child = $level2;
     $level3 = new MaxDepthDummy();
     $level3->bar = 'level3';
     $level2->child = $level3;
     $level4 = new MaxDepthDummy();
     $level4->bar = 'level4';
     $level3->child = $level4;
     $result = $serializer->normalize($level1, null, array(GetSetMethodNormalizer::ENABLE_MAX_DEPTH => true));
     $expected = array('bar' => 'level1', 'child' => array('bar' => 'level2', 'child' => array('bar' => 'level3', 'child' => array('child' => null))));
     $this->assertEquals($expected, $result);
 }
 protected function setUp()
 {
     $this->normalizer = new GetSetMethodNormalizer();
     $this->normalizer->setSerializer($this->getMock('Symfony\\Component\\Serializer\\Serializer'));
 }