Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Commit2319d6a
committed
bug#4213 Handle "constraints" option in form unit testing (sarcher)
This PR was submitted for the 2.5 branch but it was merged into the 2.3 branch instead (closes#4213).Discussion----------Handle "constraints" option in form unit testingIn the current documentation, although a mocked `ValidatorInterface` is being passed to the `FormTypeValidatorExtension`, the actual `validate()` method in it is returning null. This causes any test against a form type that utilizes the extension's `constraints` option to fail, because of the following code in `Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener`:```php // Validate the form in group "Default" $violations = $this->validator->validate($form); foreach ($violations as $violation) { // Allow the "invalid" constraint to be put onto // non-synchronized forms $allowNonSynchronized = Form::ERR_INVALID === $violation->getCode(); $this->violationMapper->mapViolation($violation, $form, $allowNonSynchronized); }```Note the `foreach` loop that is expecting an array; currently the mocked object returns null and any test fails.Since the documentation uses the `ValidatorExtension` as a specific example, I think it would be nice for the example code to handle this case, preventing the user from having to dig deeper into the code to discover the problem.Commits-------3746f07 Fixed return value8251e79 Handle "constraints" option in form unit testing1 file changed
+5
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
186 | 190 | | |
187 | 191 | | |
188 | 192 | | |
189 | 193 | | |
190 | 194 | | |
191 | | - | |
| 195 | + | |
192 | 196 | | |
193 | 197 | | |
194 | 198 | | |
| |||
0 commit comments
Comments
(0)