11
11
12
12
namespace Symfony \Component \Validator \Tests \Constraints ;
13
13
14
- use Symfony \Component \Validator \Constraints \AtLeastOne ;
15
- use Symfony \Component \Validator \Constraints \AtLeastOneValidator ;
14
+ use Symfony \Component \Validator \Constraints \AtLeastOneOf ;
15
+ use Symfony \Component \Validator \Constraints \AtLeastOneOfValidator ;
16
16
use Symfony \Component \Validator \Constraints \Choice ;
17
17
use Symfony \Component \Validator \Constraints \Count ;
18
18
use Symfony \Component \Validator \Constraints \Country ;
29
29
use Symfony \Component \Validator \Constraints \Unique ;
30
30
use Symfony \Component \Validator \Test \ConstraintValidatorTestCase ;
31
31
32
- class AtLeastOneValidatorTest extends ConstraintValidatorTestCase
32
+ /**
33
+ * @author Przemysław Bogusz <przemyslaw.bogusz@tubotax.pl>
34
+ */
35
+ class AtLeastOneOfValidatorTest extends ConstraintValidatorTestCase
33
36
{
34
37
protected function createValidator ()
35
38
{
36
- return new AtLeastOneValidator ();
39
+ return new AtLeastOneOfValidator ();
37
40
}
38
41
39
42
/**
@@ -47,7 +50,7 @@ public function testValidCombinations($value, $constraints)
47
50
$ this ->expectViolationsAt ($ i ++, $ value , $ constraint );
48
51
}
49
52
50
- $ this ->validator ->validate ($ value , new AtLeastOne ($ constraints ));
53
+ $ this ->validator ->validate ($ value , new AtLeastOneOf ($ constraints ));
51
54
52
55
$ this ->assertNoViolation ();
53
56
}
@@ -91,37 +94,37 @@ public function getValidCombinations()
91
94
*/
92
95
public function testInvalidCombinationsWithDefaultMessage ($ value , $ constraints )
93
96
{
94
- $ atLeastOne = new AtLeastOne (['constraints ' => $ constraints ]);
97
+ $ atLeastOneOf = new AtLeastOneOf (['constraints ' => $ constraints ]);
95
98
96
- $ message = [$ atLeastOne ->message ];
99
+ $ message = [$ atLeastOneOf ->message ];
97
100
98
101
$ i = 0 ;
99
102
100
103
foreach ($ constraints as $ constraint ) {
101
104
$ message [] = ' [ ' .($ i + 1 ).'] ' .$ this ->expectViolationsAt ($ i ++, $ value , $ constraint )->get (0 )->getMessage ();
102
105
}
103
106
104
- $ this ->validator ->validate ($ value , $ atLeastOne );
107
+ $ this ->validator ->validate ($ value , $ atLeastOneOf );
105
108
106
- $ this ->buildViolation (implode ('' , $ message ))->setCode (AtLeastOne ::AT_LEAST_ONE_ERROR )->assertRaised ();
109
+ $ this ->buildViolation (implode ('' , $ message ))->setCode (AtLeastOneOf ::AT_LEAST_ONE_ERROR )->assertRaised ();
107
110
}
108
111
109
112
/**
110
113
* @dataProvider getInvalidCombinations
111
114
*/
112
115
public function testInvalidCombinationsWithCustomMessage ($ value , $ constraints )
113
116
{
114
- $ atLeastOne = new AtLeastOne (['constraints ' => $ constraints , 'message ' => 'foo ' , 'includeInternalMessages ' => false ]);
117
+ $ atLeastOneOf = new AtLeastOneOf (['constraints ' => $ constraints , 'message ' => 'foo ' , 'includeInternalMessages ' => false ]);
115
118
116
119
$ i = 0 ;
117
120
118
121
foreach ($ constraints as $ constraint ) {
119
122
$ this ->expectViolationsAt ($ i ++, $ value , $ constraint );
120
123
}
121
124
122
- $ this ->validator ->validate ($ value , $ atLeastOne );
125
+ $ this ->validator ->validate ($ value , $ atLeastOneOf );
123
126
124
- $ this ->buildViolation ('foo ' )->setCode (AtLeastOne ::AT_LEAST_ONE_ERROR )->assertRaised ();
127
+ $ this ->buildViolation ('foo ' )->setCode (AtLeastOneOf ::AT_LEAST_ONE_ERROR )->assertRaised ();
125
128
}
126
129
127
130
public function getInvalidCombinations ()
0 commit comments