You are here

public function ObjectNormalizerTest::testGroupsDenormalize in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/serializer/Tests/Normalizer/ObjectNormalizerTest.php \Symfony\Component\Serializer\Tests\Normalizer\ObjectNormalizerTest::testGroupsDenormalize()

File

vendor/symfony/serializer/Tests/Normalizer/ObjectNormalizerTest.php, line 210

Class

ObjectNormalizerTest
@author Kévin Dunglas <dunglas@gmail.com>

Namespace

Symfony\Component\Serializer\Tests\Normalizer

Code

public function testGroupsDenormalize() {
  $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
  $this->normalizer = new ObjectNormalizer($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);
}