|
14 | 14 | use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
|
15 | 15 | use Symfony\Component\Form\ChoiceList\View\ChoiceView;
|
16 | 16 | use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
|
| 17 | +use Symfony\Component\Form\Test\TypeTestCase; |
17 | 18 |
|
18 |
| -class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase |
| 19 | +class ChoiceTypeTest extends TypeTestCase |
19 | 20 | {
|
20 | 21 | private $choices = array(
|
21 | 22 | 'Bernhard' => 'a',
|
@@ -2298,4 +2299,30 @@ public function testCustomChoiceTypeDoesNotInheritChoiceLabels()
|
2298 | 2299 | // In this case the 'choice_label' closure returns null and not the closure from the first choice type.
|
2299 | 2300 | $this->assertNull($form->get('subChoice')->getConfig()->getOption('choice_label'));
|
2300 | 2301 | }
|
| 2302 | + |
| 2303 | + /** |
| 2304 | + * @dataProvider invalidNestedValueTestMatrix |
| 2305 | + */ |
| 2306 | + public function testSubmitInvalidNestedValue($multiple, $expanded, $submissionData) |
| 2307 | + { |
| 2308 | + $form = $this->factory->create('choice', null, array( |
| 2309 | + 'choices' => $this->choices, |
| 2310 | + 'multiple' => $multiple, |
| 2311 | + 'expanded' => $expanded, |
| 2312 | + )); |
| 2313 | + |
| 2314 | + $form->submit($submissionData); |
| 2315 | + $this->assertFalse($form->isSynchronized()); |
| 2316 | + $this->assertEquals('All choices submitted must be NULL or strings.', $form->getTransformationFailure()->getMessage()); |
| 2317 | + } |
| 2318 | + |
| 2319 | + public function invalidNestedValueTestMatrix() |
| 2320 | + { |
| 2321 | + return array( |
| 2322 | + 'non-multiple, non-expanded' => array(false, false, array(array())), |
| 2323 | + 'non-multiple, expanded' => array(false, true, array(array())), |
| 2324 | + 'multiple, non-expanded' => array(true, false, array(array())), |
| 2325 | + 'multiple, expanded' => array(true, true, array(array())), |
| 2326 | + ); |
| 2327 | + } |
2301 | 2328 | }
|
0 commit comments