File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,8 @@ class MaxDepth
30
30
31
31
public function __construct (array $ data )
32
32
{
33
- if (!isset ($ data ['value ' ]) || ! $ data [ ' value ' ] ) {
34
- throw new InvalidArgumentException (sprintf ('Parameter of annotation "%s" cannot be empty . ' , get_class ($ this )));
33
+ if (!isset ($ data ['value ' ])) {
34
+ throw new InvalidArgumentException (sprintf ('Parameter of annotation "%s" should be set . ' , get_class ($ this )));
35
35
}
36
36
37
37
if (!is_int ($ data ['value ' ]) || $ data ['value ' ] <= 0 ) {
Original file line number Diff line number Diff line change @@ -20,26 +20,32 @@ class MaxDepthTest extends \PHPUnit_Framework_TestCase
20
20
{
21
21
/**
22
22
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
23
+ * @expectedExceptionMessage Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" should be set.
23
24
*/
24
25
public function testNotSetMaxDepthParameter ()
25
26
{
26
27
new MaxDepth (array ());
27
28
}
28
29
29
- /**
30
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
31
- */
32
- public function testEmptyMaxDepthParameter ()
30
+ public function provideInvalidValues ()
33
31
{
34
- new MaxDepth (array ('value ' => '' ));
32
+ return array (
33
+ array ('' ),
34
+ array ('foo ' ),
35
+ array ('1 ' ),
36
+ array (0 ),
37
+ );
35
38
}
36
39
37
40
/**
41
+ * @dataProvider provideInvalidValues
42
+ *
38
43
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
44
+ * @expectedExceptionMessage Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" must be a positive integer.
39
45
*/
40
- public function testNotAnIntMaxDepthParameter ()
46
+ public function testNotAnIntMaxDepthParameter ($ value )
41
47
{
42
- new MaxDepth (array ('value ' => ' foo ' ));
48
+ new MaxDepth (array ('value ' => $ value ));
43
49
}
44
50
45
51
public function testMaxDepthParameters ()
You can’t perform that action at this time.
0 commit comments