GroupsTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\Groups;
  12. /**
  13. * @author Kévin Dunglas <dunglas@gmail.com>
  14. */
  15. class GroupsTest extends \PHPUnit_Framework_TestCase
  16. {
  17. /**
  18. * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
  19. */
  20. public function testEmptyGroupsParameter()
  21. {
  22. new Groups(array('value' => array()));
  23. }
  24. /**
  25. * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
  26. */
  27. public function testNotAnArrayGroupsParameter()
  28. {
  29. new Groups(array('value' => 'coopTilleuls'));
  30. }
  31. /**
  32. * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
  33. */
  34. public function testInvalidGroupsParameter()
  35. {
  36. new Groups(array('value' => array('a', 1, new \stdClass())));
  37. }
  38. public function testGroupsParameters()
  39. {
  40. $validData = array('a', 'b');
  41. $groups = new Groups(array('value' => $validData));
  42. $this->assertEquals($validData, $groups->getGroups());
  43. }
  44. }