public function testGroupsDenormalize() { $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); $this->normalizer = new PropertyNormalizer($classMetadataFactory); $this->normalizer->setSerializer($this->serializer); $obj = new GroupDummy(); $obj->setFoo('foo'); $toNormalize = array('foo' => 'foo', 'bar' => 'bar'); $normalized = $this->normalizer->denormalize($toNormalize, 'Symfony\\Component\\Serializer\\Tests\\Fixtures\\GroupDummy', null, array('groups' => array('a'))); $this->assertEquals($obj, $normalized); $obj->setBar('bar'); $normalized = $this->normalizer->denormalize($toNormalize, 'Symfony\\Component\\Serializer\\Tests\\Fixtures\\GroupDummy', null, array('groups' => array('a', 'b'))); $this->assertEquals($obj, $normalized); }
public function testDenormalizeNonExistingAttribute() { $this->assertEquals(new PropertyDummy(), $this->normalizer->denormalize(array('non_existing' => true), __NAMESPACE__ . '\\PropertyDummy')); }
public function testDenormalizeShouldIgnoreStaticProperty() { $obj = $this->normalizer->denormalize(array('outOfScope' => true), __NAMESPACE__ . '\\PropertyDummy'); $this->assertEquals(new PropertyDummy(), $obj); $this->assertEquals('out_of_scope', PropertyDummy::$outOfScope); }
public function testConstructorDenormalize() { $obj = $this->normalizer->denormalize(array('foo' => 'foo', 'bar' => 'bar'), __NAMESPACE__ . '\\PropertyConstructorDummy', 'any'); $this->assertEquals('foo', $obj->getFoo()); $this->assertEquals('bar', $obj->getBar()); }