public function testGroupsDenormalizeWithNameConverter() { $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); $this->normalizer = new ObjectNormalizer($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter()); $this->normalizer->setSerializer($this->serializer); $obj = new GroupDummy(); $obj->setFooBar('@dunglas'); $obj->setSymfony('@coopTilleuls'); $this->assertEquals($obj, $this->normalizer->denormalize(array('bar' => null, 'foo_bar' => '@dunglas', 'symfony' => '@coopTilleuls', 'coop_tilleuls' => 'les-tilleuls.coop'), 'Symfony\\Component\\Serializer\\Tests\\Fixtures\\GroupDummy', null, array(ObjectNormalizer::GROUPS => array('name_converter')))); }
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); }