@@ -32,6 +32,14 @@ class ChoiceTypeTest extends TypeTestCase
32
32
4 => 'Roman ' ,
33
33
);
34
34
35
+ private $ stringButNumericChoices = array (
36
+ '0 ' => 'Bernhard ' ,
37
+ '1 ' => 'Fabien ' ,
38
+ '2 ' => 'Kris ' ,
39
+ '3 ' => 'Jon ' ,
40
+ '4 ' => 'Roman ' ,
41
+ );
42
+
35
43
protected $ groupedChoices = array (
36
44
'Symfony ' => array (
37
45
'a ' => 'Bernhard ' ,
@@ -181,7 +189,30 @@ public function testBindSingleExpandedNumericChoices()
181
189
182
190
$ form ->bind ('1 ' );
183
191
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 ,
7362
tr>
209
+ 'expanded ' => true ,
210
+ 'choices ' => $ this ->stringButNumericChoices ,
211
+ ));
212
+
213
+ $ form ->bind ('1 ' );
214
+
215
+ $ this ->assertSame ('1 ' , $ form ->getData ());
185
216
$ this ->assertSame (false , $ form [0 ]->getData ());
186
217
$ this ->assertSame (true , $ form [1 ]->getData ());
187
218
$ this ->assertSame (false , $ form [2 ]->getData ());
0 commit comments