2014-10-01 16:10:16 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Symfony\Component\Serializer\Tests\Annotation;
|
|
|
|
|
2017-02-08 07:24:27 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2014-10-01 16:10:16 +01:00
|
|
|
use Symfony\Component\Serializer\Annotation\Groups;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Kévin Dunglas <dunglas@gmail.com>
|
|
|
|
*/
|
2017-02-08 07:24:27 +00:00
|
|
|
class GroupsTest extends TestCase
|
2014-10-01 16:10:16 +01:00
|
|
|
{
|
|
|
|
/**
|
2015-07-03 13:43:05 +01:00
|
|
|
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
|
2014-10-01 16:10:16 +01:00
|
|
|
*/
|
|
|
|
public function testEmptyGroupsParameter()
|
|
|
|
{
|
|
|
|
new Groups(array('value' => array()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-03 13:43:05 +01:00
|
|
|
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
|
2014-10-01 16:10:16 +01:00
|
|
|
*/
|
|
|
|
public function testNotAnArrayGroupsParameter()
|
|
|
|
{
|
2016-11-13 19:28:52 +00:00
|
|
|
new Groups(array('value' => 12));
|
2014-10-01 16:10:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-03 13:43:05 +01:00
|
|
|
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
|
2014-10-01 16:10:16 +01:00
|
|
|
*/
|
|
|
|
public function testInvalidGroupsParameter()
|
|
|
|
{
|
|
|
|
new Groups(array('value' => array('a', 1, new \stdClass())));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGroupsParameters()
|
|
|
|
{
|
|
|
|
$validData = array('a', 'b');
|
|
|
|
|
|
|
|
$groups = new Groups(array('value' => $validData));
|
|
|
|
$this->assertEquals($validData, $groups->getGroups());
|
|
|
|
}
|
2016-11-13 19:28:52 +00:00
|
|
|
|
|
|
|
public function testSingleGroup()
|
|
|
|
{
|
|
|
|
$groups = new Groups(array('value' => 'a'));
|
|
|
|
$this->assertEquals(array('a'), $groups->getGroups());
|
|
|
|
}
|
2014-10-01 16:10:16 +01:00
|
|
|
}
|