@@ -23,7 +23,7 @@ protected function createValidator()
23
23
}
24
24
25
25
/**
26
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
26
+ * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
27
27
*/
28
28
public function testExpectsUniqueConstraintCompatibleType ()
29
29
{
@@ -42,29 +42,29 @@ public function testValidValues($value)
42
42
43
43
public function getValidValues ()
44
44
{
45
- return array (
46
- yield 'null ' => array ( array ( null )) ,
47
- yield 'empty array ' => array ( array ()) ,
48
- yield 'single integer ' => array ( array ( 5 )) ,
49
- yield 'single string ' => array ( array ( 'a ' )) ,
50
- yield 'single object ' => array ( array ( new \stdClass ())) ,
51
- yield 'unique booleans ' => array ( array ( true , false )) ,
52
- yield 'unique integers ' => array ( array ( 1 , 2 , 3 , 4 , 5 , 6 )) ,
53
- yield 'unique floats ' => array ( array ( 0.1 , 0.2 , 0.3 )) ,
54
- yield 'unique strings ' => array ( array ( 'a ' , 'b ' , 'c ' )) ,
55
- yield 'unique arrays ' => array ( array ( array ( 1 , 2 ), array ( 2 , 4 ), array ( 4 , 6 ))) ,
56
- yield 'unique objects ' => array ( array ( new \stdClass (), new \stdClass ())) ,
57
- ) ;
45
+ return [
46
+ yield 'null ' => [[ null ]] ,
47
+ yield 'empty array ' => [[]] ,
48
+ yield 'single integer ' => [[ 5 ]] ,
49
+ yield 'single string ' => [[ 'a ' ]] ,
50
+ yield 'single object ' => [[ new \stdClass ()]] ,
51
+ yield 'unique booleans ' => [[ true , false ]] ,
52
+ yield 'unique integers ' => [[ 1 , 2 , 3 , 4 , 5 , 6 ]] ,
53
+ yield 'unique floats ' => [[ 0.1 , 0.2 , 0.3 ]] ,
54
+ yield 'unique strings ' => [[ 'a ' , 'b ' , 'c ' ]] ,
55
+ yield 'unique arrays ' => [[[ 1 , 2 ], [ 2 , 4 ], [ 4 , 6 ]]] ,
56
+ yield 'unique objects ' => [[ new \stdClass (), new \stdClass ()]] ,
57
+ ] ;
58
58
}
59
59
60
60
/**
61
61
* @dataProvider getInvalidValues
62
62
*/
63
63
public function testInvalidValues ($ value )
64
64
{
65
- $ constraint = new Unique (array (
65
+ $ constraint = new Unique ([
66
66
'message ' => 'myMessage ' ,
67
- ) );
67
+ ] );
68
68
$ this ->validator ->validate ($ value , $ constraint );
69
69
70
70
$ this ->buildViolation ('myMessage ' )
@@ -77,13 +77,13 @@ public function getInvalidValues()
77
77
{
78
78
$ object = new \stdClass ();
79
79
80
- return array (
81
- yield 'not unique booleans ' => array ( array ( true , true )) ,
82
- yield 'not unique integers ' => array ( array ( 1 , 2 , 3 , 3 )) ,
83
- yield 'not unique floats ' => array ( array ( 0.1 , 0.2 , 0.1 )) ,
84
- yield 'not unique string ' => array ( array ( 'a ' , 'b ' , 'a ' )) ,
85
- yield 'not unique arrays ' => array ( array ( array ( 1 , 1 ), array ( 2 , 3 ), array ( 1 , 1 ))) ,
86
- yield 'not unique objects ' => array ( array ( $ object , $ object)) ,
87
- ) ;
80
+ return [
81
+ yield 'not unique booleans ' => [[ true , true ]] ,
82
+ yield 'not unique integers ' => [[ 1 , 2 , 3 , 3 ]] ,
83
+ yield 'not unique floats ' => [[ 0.1 , 0.2 , 0.1 ]] ,
84
+ yield 'not unique string ' => [[ 'a ' , 'b ' , 'a ' ]] ,
85
+ yield 'not unique arrays ' => [[[ 1 , 1 ], [ 2 , 3 ], [ 1 , 1 ]]] ,
86
+ yield 'not unique objects ' => [[ $ object , $ object]] ,
87
+ ] ;
88
88
}
89
89
}
0 commit comments