public function testIgnoredAttributes()
 {
     $this->normalizer->setIgnoredAttributes(array('foo', 'bar', 'camelCase'));
     $obj = new PropertyDummy();
     $obj->foo = 'foo';
     $obj->setBar('bar');
     $this->assertEquals(array(), $this->normalizer->normalize($obj, 'any'));
 }
 /**
  * @expectedException \Symfony\Component\Serializer\Exception\LogicException
  * @expectedExceptionMessage Cannot normalize attribute "bar" because injected serializer is not a normalizer
  */
 public function testUnableToNormalizeObjectAttribute()
 {
     $serializer = $this->getMock('Symfony\\Component\\Serializer\\SerializerInterface');
     $this->normalizer->setSerializer($serializer);
     $obj = new PropertyDummy();
     $object = new \stdClass();
     $obj->setBar($object);
     $this->normalizer->normalize($obj, 'any');
 }
Exemplo n.º 3
0
 public function testCircularReferenceHandler()
 {
     $serializer = new Serializer(array($this->normalizer));
     $this->normalizer->setSerializer($serializer);
     $this->normalizer->setCircularReferenceHandler(function ($obj) {
         return get_class($obj);
     });
     $obj = new PropertyCircularReferenceDummy();
     $expected = array('me' => 'Symfony\\Component\\Serializer\\Tests\\Fixtures\\PropertyCircularReferenceDummy');
     $this->assertEquals($expected, $this->normalizer->normalize($obj));
 }