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 ObjectNormalizer($classMetadataFactory);
     $serializer = new Serializer(array($this->normalizer));
     $this->normalizer->setSerializer($serializer);
     $level1 = new MaxDepthDummy();
     $level1->foo = 'level1';
     $level2 = new MaxDepthDummy();
     $level2->foo = 'level2';
     $level1->child = $level2;
     $level3 = new MaxDepthDummy();
     $level3->foo = 'level3';
     $level2->child = $level3;
     $result = $serializer->normalize($level1, null, array(ObjectNormalizer::ENABLE_MAX_DEPTH => true));
     $expected = array('bar' => null, 'foo' => 'level1', 'child' => array('bar' => null, 'foo' => 'level2', 'child' => array('bar' => null, 'child' => null)));
     $this->assertEquals($expected, $result);
 }