4554fc9905ca674a6f609ebdd9e2ab3be206a402
[yaffs-website] / serializer / Tests / Annotation / MaxDepthTest.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\Annotation;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Serializer\Annotation\MaxDepth;
16
17 /**
18  * @author Kévin Dunglas <dunglas@gmail.com>
19  */
20 class MaxDepthTest extends TestCase
21 {
22     /**
23      * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
24      * @expectedExceptionMessage Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" should be set.
25      */
26     public function testNotSetMaxDepthParameter()
27     {
28         new MaxDepth(array());
29     }
30
31     public function provideInvalidValues()
32     {
33         return array(
34             array(''),
35             array('foo'),
36             array('1'),
37             array(0),
38         );
39     }
40
41     /**
42      * @dataProvider provideInvalidValues
43      *
44      * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
45      * @expectedExceptionMessage Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" must be a positive integer.
46      */
47     public function testNotAnIntMaxDepthParameter($value)
48     {
49         new MaxDepth(array('value' => $value));
50     }
51
52     public function testMaxDepthParameters()
53     {
54         $maxDepth = new MaxDepth(array('value' => 3));
55         $this->assertEquals(3, $maxDepth->getMaxDepth());
56     }
57 }