MaxDepthTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Serializer\Tests\Annotation;
  11. use Symfony\Component\Serializer\Annotation\MaxDepth;
  12. /**
  13. * @author Kévin Dunglas <dunglas@gmail.com>
  14. */
  15. class MaxDepthTest extends \PHPUnit_Framework_TestCase
  16. {
  17. /**
  18. * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
  19. * @expectedExceptionMessage Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" should be set.
  20. */
  21. public function testNotSetMaxDepthParameter()
  22. {
  23. new MaxDepth(array());
  24. }
  25. public function provideInvalidValues()
  26. {
  27. return array(
  28. array(''),
  29. array('foo'),
  30. array('1'),
  31. array(0),
  32. );
  33. }
  34. /**
  35. * @dataProvider provideInvalidValues
  36. *
  37. * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
  38. * @expectedExceptionMessage Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" must be a positive integer.
  39. */
  40. public function testNotAnIntMaxDepthParameter($value)
  41. {
  42. new MaxDepth(array('value' => $value));
  43. }
  44. public function testMaxDepthParameters()
  45. {
  46. $maxDepth = new MaxDepth(array('value' => 3));
  47. $this->assertEquals(3, $maxDepth->getMaxDepth());
  48. }
  49. }