You are here

public function GetSetMethodNormalizerTest::testGroupsNormalize in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php \Symfony\Component\Serializer\Tests\Normalizer\GetSetMethodNormalizerTest::testGroupsNormalize()

File

vendor/symfony/serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php, line 262

Class

GetSetMethodNormalizerTest

Namespace

Symfony\Component\Serializer\Tests\Normalizer

Code

public function testGroupsNormalize() {
  $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
  $this->normalizer = new GetSetMethodNormalizer($classMetadataFactory);
  $this->normalizer
    ->setSerializer($this->serializer);
  $obj = new GroupDummy();
  $obj
    ->setFoo('foo');
  $obj
    ->setBar('bar');
  $obj
    ->setFooBar('fooBar');
  $obj
    ->setSymfony('symfony');
  $obj
    ->setKevin('kevin');
  $obj
    ->setCoopTilleuls('coopTilleuls');
  $this
    ->assertEquals(array(
    'bar' => 'bar',
  ), $this->normalizer
    ->normalize($obj, null, array(
    'groups' => array(
      'c',
    ),
  )));
  $this
    ->assertEquals(array(
    'symfony' => 'symfony',
    'foo' => 'foo',
    'fooBar' => 'fooBar',
    'bar' => 'bar',
    'kevin' => 'kevin',
    'coopTilleuls' => 'coopTilleuls',
  ), $this->normalizer
    ->normalize($obj, null, array(
    'groups' => array(
      'a',
      'c',
    ),
  )));
}