Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / serializer / Tests / Mapping / Loader / AnnotationLoaderTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Serializer\Tests\Mapping\Loader;
13
14 use Doctrine\Common\Annotations\AnnotationReader;
15 use PHPUnit\Framework\TestCase;
16 use Symfony\Component\Serializer\Mapping\ClassMetadata;
17 use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
18 use Symfony\Component\Serializer\Tests\Mapping\TestClassMetadataFactory;
19
20 /**
21  * @author Kévin Dunglas <dunglas@gmail.com>
22  */
23 class AnnotationLoaderTest extends TestCase
24 {
25     /**
26      * @var AnnotationLoader
27      */
28     private $loader;
29
30     protected function setUp()
31     {
32         $this->loader = new AnnotationLoader(new AnnotationReader());
33     }
34
35     public function testInterface()
36     {
37         $this->assertInstanceOf('Symfony\Component\Serializer\Mapping\Loader\LoaderInterface', $this->loader);
38     }
39
40     public function testLoadClassMetadataReturnsTrueIfSuccessful()
41     {
42         $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
43
44         $this->assertTrue($this->loader->loadClassMetadata($classMetadata));
45     }
46
47     public function testLoadGroups()
48     {
49         $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
50         $this->loader->loadClassMetadata($classMetadata);
51
52         $this->assertEquals(TestClassMetadataFactory::createClassMetadata(), $classMetadata);
53     }
54
55     public function testLoadMaxDepth()
56     {
57         $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy');
58         $this->loader->loadClassMetadata($classMetadata);
59
60         $attributesMetadata = $classMetadata->getAttributesMetadata();
61         $this->assertEquals(2, $attributesMetadata['foo']->getMaxDepth());
62         $this->assertEquals(3, $attributesMetadata['bar']->getMaxDepth());
63     }
64
65     public function testLoadClassMetadataAndMerge()
66     {
67         $classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
68         $parentClassMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummyParent');
69
70         $this->loader->loadClassMetadata($parentClassMetadata);
71         $classMetadata->merge($parentClassMetadata);
72
73         $this->loader->loadClassMetadata($classMetadata);
74
75         $this->assertEquals(TestClassMetadataFactory::createClassMetadata(true), $classMetadata);
76     }
77 }