26
26
use Symfony \Component \Translation \IdentityTranslator ;
27
27
use Symfony \Component \Validator \Constraints \Collection ;
28
28
use Symfony \Component \Validator \Constraints \GroupSequence ;
29
+ use Symfony \Component \Validator \Constraints \Length ;
29
30
use Symfony \Component \Validator \Constraints \NotBlank ;
30
31
use Symfony \Component \Validator \Constraints \NotNull ;
31
32
use Symfony \Component \Validator \Constraints \Valid ;
@@ -77,10 +78,11 @@ public function testValidateConstraints()
77
78
$ object = new \stdClass ();
78
79
$ constraint1 = new NotNull (['groups ' => ['group1 ' , 'group2 ' ]]);
79
80
$ constraint2 = new NotBlank (['groups ' => 'group2 ' ]);
81
+ $ constraint3 = new Length (['groups ' => 'group2 ' , 'min ' => 3 ]);
80
82
81
83
$ options = [
82
84
'validation_groups ' => ['group1 ' , 'group2 ' ],
83
- 'constraints ' => [$ constraint1 , $ constraint2 ],
85
+ 'constraints ' => [$ constraint1 , $ constraint2, $ constraint3 ],
84
86
];
85
87
$ form = $ this ->getCompoundForm ($ object , $ options );
86
88
$ form ->submit ([]);
@@ -89,8 +91,8 @@ public function testValidateConstraints()
89
91
$ this ->expectValidateAt (0 , 'data ' , $ object , ['group1 ' , 'group2 ' ]);
90
92
91
93
// Then custom constraints
92
- $ this ->expectValidateValueAt (1 , 'data ' , $ object , $ constraint1 , 'group1 ' );
93
- $ this ->expectValidateValueAt (2 , 'data ' , $ object , $ constraint2 , 'group2 ' );
94
+ $ this ->expectValidateValueAt (1 , 'data ' , $ object , [ $ constraint1] , 'group1 ' );
95
+ $ this ->expectValidateValueAt (2 , 'data ' , $ object , [ $ constraint2, $ constraint3 ] , 'group2 ' );
94
96
95
97
$ this ->validator ->validate ($ form , new Form ());
96
98
@@ -172,8 +174,8 @@ public function testValidateConstraintsOptionEvenIfNoValidConstraint()
172
174
$ parent ->add ($ form );
173
175
$ parent ->submit ([]);
174
176
175
- $ this ->expectValidateValueAt (0 , 'data ' , $ object , $ constraint1 , 'group1 ' );
176
- $ this ->expectValidateValueAt (1 , 'data ' , $ object , $ constraint2 , 'group2 ' );
177
+ $ this ->expectValidateValueAt (0 , 'data ' , $ object , [ $ constraint1] , 'group1 ' );
178
+ $ this ->expectValidateValueAt (1 , 'data ' , $ object , [ $ constraint2] , 'group2 ' );
177
179
178
180
$ this ->validator ->validate ($ form , new Form ());
179
181
0 commit comments