Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / serializer / Tests / Mapping / AttributeMetadataTest.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;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Serializer\Mapping\AttributeMetadata;
16
17 /**
18  * @author Kévin Dunglas <dunglas@gmail.com>
19  */
20 class AttributeMetadataTest extends TestCase
21 {
22     public function testInterface()
23     {
24         $attributeMetadata = new AttributeMetadata('name');
25         $this->assertInstanceOf('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface', $attributeMetadata);
26     }
27
28     public function testGetName()
29     {
30         $attributeMetadata = new AttributeMetadata('name');
31         $this->assertEquals('name', $attributeMetadata->getName());
32     }
33
34     public function testGroups()
35     {
36         $attributeMetadata = new AttributeMetadata('group');
37         $attributeMetadata->addGroup('a');
38         $attributeMetadata->addGroup('a');
39         $attributeMetadata->addGroup('b');
40
41         $this->assertEquals(array('a', 'b'), $attributeMetadata->getGroups());
42     }
43
44     public function testMaxDepth()
45     {
46         $attributeMetadata = new AttributeMetadata('name');
47         $attributeMetadata->setMaxDepth(69);
48
49         $this->assertEquals(69, $attributeMetadata->getMaxDepth());
50     }
51
52     public function testMerge()
53     {
54         $attributeMetadata1 = new AttributeMetadata('a1');
55         $attributeMetadata1->addGroup('a');
56         $attributeMetadata1->addGroup('b');
57
58         $attributeMetadata2 = new AttributeMetadata('a2');
59         $attributeMetadata2->addGroup('a');
60         $attributeMetadata2->addGroup('c');
61         $attributeMetadata2->setMaxDepth(2);
62
63         $attributeMetadata1->merge($attributeMetadata2);
64
65         $this->assertEquals(array('a', 'b', 'c'), $attributeMetadata1->getGroups());
66         $this->assertEquals(2, $attributeMetadata1->getMaxDepth());
67     }
68
69     public function testSerialize()
70     {
71         $attributeMetadata = new AttributeMetadata('attribute');
72         $attributeMetadata->addGroup('a');
73         $attributeMetadata->addGroup('b');
74         $attributeMetadata->setMaxDepth(3);
75
76         $serialized = serialize($attributeMetadata);
77         $this->assertEquals($attributeMetadata, unserialize($serialized));
78     }
79 }