8000 Test for bug #14877 · imphil/symfony@71a59b7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 71a59b7

Browse files
committed
Test for bug symfony#14877
1 parent c8e05e3 commit 71a59b7

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,101 @@ public function testSubmitSingleNonExpanded()
279279
$this->assertTrue($form->isSynchronized());
280280
}
281281

282+
public function testSubmitSingleNonExpandedInteger()
283+
{
284+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
285+
'multiple' => false,
286+
'expanded' => false,
287+
'choices' => array(
288+
'label a' => 0,
289+
'label b' => 1,
290+
),
291+
'choices_as_values' => true,
292+
));
293+
294+
$form->submit('0');
295+
296+
$this->assertSame(0, $form->getData());
297+
$this->assertSame('0', $form->getViewData());
298+
$this->assertTrue($form->isSynchronized());
299+
}
300+
301+
public function testSubmitSingleNonExpandedBooleanValueFalse()
302+
{
303+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
304+
'multiple' => false,
305+
'expanded' => false,
306+
'choices' => array(
307+
'label a' => false,
308+
'label b' => true,
309+
),
310+
'choices_as_values' => true,
311+
));
312+
313+
$form->submit('0');
314+
315+
$this->assertSame(false, $form->getData());
316+
$this->assertSame('0', $form->getViewData());
317+
$this->assertTrue($form->isSynchronized());
318+
}
319+
320+
public function testSubmitSingleNonExpandedBooleanValueTrue()
321+
{
322+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
323+
'multiple' => false,
324+
'expanded' => false,
325+
'choices' => array(
326+
'label a' => false,
327+
'label b' => true,
328+
),
329+
'choices_as_values' => true,
330+
));
331+
332+
$form->submit('1');
333+
334+
$this->assertSame(true, $form->getData());
335+
$this->assertSame('1', $form->getViewData());
336+
$this->assertTrue($form->isSynchronized());
337+
}
338+
339+
public function testSubmitSingleExpandedBooleanValueFalse()
340+
{
341+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
342+
'multiple' => false,
343+
'expanded' => true,
344+
'choices' => array(
345+
'label a' => false,
346+
'label b' => true,
347+
),
348+
'choices_as_values' => true,
349+
));
350+
351+
$form->submit('0');
352+
353+
$this->assertSame(false, $form->getData());
354+
$this->assertSame('0', $form->getViewData());
355+
$this->assertTrue($form->isSynchronized());
356+
}
357+
358+
public function testSubmitSingleExpandedBooleanValueTrue()
359+
{
360+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
361+
'multiple' => false,
362+
'expanded' => true,
363+
'choices' => array(
364+
'label a' => false,
365+
'label b' => true,
366+
),
367+
'choices_as_values' => true,
368+
));
369+
370+
$form->submit('1');
371+
372+
$this->assertSame(true, $form->getData());
373+
$this->assertSame('1', $form->getViewData());
374+
$this->assertTrue($form->isSynchronized());
375+
}
376+
282377
public function testSubmitSingleNonExpandedInvalidChoice()
283378
{
284379
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(

0 commit comments

Comments
 (0)
0