[Serializer] Improve test coverage of the MaxDepth annotation

This commit is contained in:
Kévin Dunglas 2016-11-15 08:36:22 +01:00
parent 61fea5a3f1
commit 531169656e
No known key found for this signature in database
GPG Key ID: 4D04EBEF06AAF3A6

View File

@ -18,6 +18,22 @@ use Symfony\Component\Serializer\Annotation\MaxDepth;
*/ */
class MaxDepthTest extends \PHPUnit_Framework_TestCase class MaxDepthTest extends \PHPUnit_Framework_TestCase
{ {
/**
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
*/
public function testNotSetMaxDepthParameter()
{
new MaxDepth(array());
}
/**
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
*/
public function testEmptyMaxDepthParameter()
{
new MaxDepth(array('value' => ''));
}
/** /**
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
*/ */
@ -28,9 +44,7 @@ class MaxDepthTest extends \PHPUnit_Framework_TestCase
public function testMaxDepthParameters() public function testMaxDepthParameters()
{ {
$validData = 3; $maxDepth = new MaxDepth(array('value' => 3));
$this->assertEquals(3, $maxDepth->getMaxDepth());
$groups = new MaxDepth(array('value' => 3));
$this->assertEquals($validData, $groups->getMaxDepth());
} }
} }