|
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 | use Symfony\Component\Form\Tests\Fixtures\ChoiceSubType;
|
18 | 19 |
|
19 |
| -class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase |
| 20 | +class ChoiceTypeTest extends TypeTestCase |
20 | 21 | {
|
21 | 22 | private $choices = array(
|
22 | 23 | 'Bernhard' => 'a',
|
@@ -2283,4 +2284,30 @@ public function testCustomChoiceTypeDoesNotInheritChoiceLabels()
|
2283 | 2284 | // In this case the 'choice_label' closure returns null and not the closure from the first choice type.
|
2284 | 2285 | $this->assertNull($form->get('subChoice')->getConfig()->getOption('choice_label'));
|
2285 | 2286 | }
|
| 2287 | + |
| 2288 | + /** |
| 2289 | + * @dataProvider invalidNestedValueTestMatrix |
| 2290 | + */ |
| 2291 | + public function testSubmitInvalidNestedValue($multiple, $expanded, $submissionData) |
| 2292 | + { |
| 2293 | + $form = $this->factory->create('choice', null, array( |
| 2294 | + 'choices' => $this->choices, |
| 2295 | + 'multiple' => $multiple, |
| 2296 | + 'expanded' => $expanded, |
| 2297 | + )); |
| 2298 | + |
| 2299 | + $form->submit($submissionData); |
| 2300 | + $this->assertFalse($form->isSynchronized()); |
| 2301 | + $this->assertEquals('All choices submitted must be NULL or strings.', $form->getTransformationFailure()->getMessage()); |
| 2302 | + } |
| 2303 | + |
| 2304 | + public function invalidNestedValueTestMatrix() |
| 2305 | + { |
| 2306 | + return array( |
| 2307 | + 'non-multiple, non-expanded' => array(false, false, array(array())), |
| 2308 | + 'non-multiple, expanded' => array(false, true, array(array())), |
| 2309 | + 'multiple, non-expanded' => array(true, false, array(array())), |
| 2310 | + 'multiple, expanded' => array(true, true, array(array())), |
| 2311 | + ); |
| 2312 | + } |
2286 | 2313 | }
|
0 commit comments