8000 [Form] fixed unit tests for previous commit · renegare/symfony@65e9373 · GitHub
[go: up one dir, main page]

Skip to content

Commit 65e9373

Browse files
committed
[Form] fixed unit tests for previous commit
1 parent 2573c89 commit 65e9373

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ class ChoiceTypeTest extends TypeTestCase
3232
4 => 'Roman',
3333
);
3434

35+
private $stringButNumericChoices = array(
36+
'0' => 'Bernhard',
37+
'1' => 'Fabien',
38+
'2' => 'Kris',
39+
'3' => 'Jon',
40+
'4' => 'Roman',
41+
);
42+
3543
protected $groupedChoices = array(
3644
'Symfony' => array(
3745
'a' => 'Bernhard',
@@ -181,7 +189,30 @@ public function testBindSingleExpandedNumericChoices()
181189

182190
$form->bind('1');
183191

184-
$this->assertSame(1, $form->getData());
192+
$this->assertSame('1', $form->getData());
193+
$this->assertSame(false, $form[0]->getData());
194+
$this->assertSame(true, $form[1]->getData());
195+
$this->assertSame(false, $form[2]->getData());
196+
$this->assertSame(false, $form[3]->getData());
197+
$this->assertSame(false, $form[4]->getData());
198+
$this->assertSame('', $form[0]->getClientData());
199+
$this->assertSame('1', $form[1]->getClientData());
200+
$this->assertSame('', $form[2]->getClientData());
201+
$this->assertSame('', $form[3]->getClientData());
202+
$this->assertSame('', $form[4]->getClientData());
203+
}
204+
205+
public function testBindSingleExpandedStringsButNumericChoices()
206+
{
207+
$form = $this->factory->create('choice', null, array(
208+
'multiple' => false,
209+
'expanded' => true,
210+
'choices' => $this->stringButNumericChoices,
211+
));
212+
213+
$form->bind('1');
214+
215+
$this->assertSame('1', $form->getData());
185216
$this->assertSame(false, $form[0]->getData());
186217
$this->assertSame(true, $form[1]->getData());
187218
$this->assertSame(false, $form[2]->getData());

0 commit comments

Comments
 (0)
0