Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a16e87

Browse files
[Form] Fix missing choices_as_values=true in tests
1 parent ff582b8 commit 2a16e87

File tree

3 files changed

+104
-53
lines changed

3 files changed

+104
-53
lines changed

src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ public function testCheckboxWithValue()
212212
public function testSingleChoice()
213213
{
214214
$form = $this->factory->createNamed('name', 'choice', '&a', array(
215-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
215+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
216+
'choices_as_values' => true,
216217
'multiple' => false,
217218
'expanded' => false,
218219
));
@@ -234,7 +235,8 @@ public function testSingleChoice()
234235
public function testSingleChoiceWithoutTranslation()
235236
{
236237
$form = $this->factory->createNamed('name', 'choice', '&a', array(
237-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
238+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
239+
'choices_as_values' => true,
238240
'multiple' => false,
239241
'expanded' => false,
240242
'choice_translation_domain' => false,
@@ -257,7 +259,8 @@ public function testSingleChoiceWithoutTranslation()
257259
public function testSingleChoiceAttributes()
258260
{
259261
$form = $this->factory->createNamed('name', 'choice', '&a', array(
260-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
262+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
263+
'choices_as_values' => true,
261264
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
262265
'multiple' => false,
263266
'expanded' => false,
@@ -282,7 +285,8 @@ public function testSingleChoiceAttributes()
282285
public function testSingleChoiceWithPreferred()
283286
{
284287
$form = $this->factory->createNamed('name', 'choice', '&a', array(
285-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
288+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
289+
'choices_as_values' => true,
286290
'preferred_choices' => array('&b'),
287291
'multiple' => false,
288292
'expanded' => false,
@@ -306,7 +310,8 @@ public function testSingleChoiceWithPreferred()
306310
public function testSingleChoiceWithPreferredAndNoSeparator()
307311
{
308312
$form = $this->factory->createNamed('name', 'choice', '&a', array(
309-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
313+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
314+
'choices_as_values' => true,
310315
'preferred_choices' => array('&b'),
311316
'multiple' => false,
312317
'expanded' => false,
@@ -329,7 +334,8 @@ public function testSingleChoiceWithPreferredAndNoSeparator()
329334
public function testSingleChoiceWithPreferredAndBlankSeparator()
330335
{
331336
$form = $this->factory->createNamed('name', 'choice', '&a', array(
332-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
337+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
338+
'choices_as_values' => true,
333339
'preferred_choices' => array('&b'),
334340
'multiple' => false,
335341
'expanded' => false,
@@ -353,7 +359,8 @@ public function testSingleChoiceWithPreferredAndBlankSeparator()
353359
public function testChoiceWithOnlyPreferred()
354360
{
355361
$form = $this->factory->createNamed('name', 'choice', '&a', array(
356-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
362+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
363+
'choices_as_values' => true,
357364
'preferred_choices' => array('&a', '&b'),
358365
'multiple' => false,
359366
'expanded' => false,
@@ -370,7 +377,8 @@ public function testChoiceWithOnlyPreferred()
370377
public function testSingleChoiceNonRequired()
371378
{
372379
$form = $this->factory->createNamed('name', 'choice', '&a', array(
373-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
380+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
381+
'choices_as_values' => true,
374382
'required' => false,
375383
'multiple' => false,
376384
'expanded' => false,
@@ -394,7 +402,8 @@ public function testSingleChoiceNonRequired()
394402
public function testSingleChoiceNonRequiredNoneSelected()
395403
{
396404
$form = $this->factory->createNamed('name', 'choice', null, array(
397-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
405+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
406+
'choices_as_values' => true,
398407
'required' => false,
399408
'multiple' => false,
400409
'expanded' => false,
@@ -418,7 +427,8 @@ public function testSingleChoiceNonRequiredNoneSelected()
418427
public function testSingleChoiceNonRequiredWithPlaceholder()
419428
{
420429
$form = $this->factory->createNamed('name', 'choice', '&a', array(
421-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
430+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
431+
'choices_as_values' => true,
422432
'multiple' => false,
423433
'expanded' => false,
424434
'required' => false,
@@ -443,7 +453,8 @@ public function testSingleChoiceNonRequiredWithPlaceholder()
443453
public function testSingleChoiceRequiredWithPlaceholder()
444454
{
445455
$form = $this->factory->createNamed('name', 'choice', '&a', array(
446-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
456+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
457+
'choices_as_values' => true,
447458
'required' => true,
448459
'multiple' => false,
449460
'expanded' => false,
@@ -468,7 +479,8 @@ public function testSingleChoiceRequiredWithPlaceholder()
468479
public function testSingleChoiceRequiredWithPlaceholderViaView()
469480
{
470481
$form = $this->factory->createNamed('name', 'choice', '&a', array(
471-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
482+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
483+
'choices_as_values' => true,
472484
'required' => true,
473485
'multiple' => false,
474486
'expanded' => false,
@@ -493,9 +505,10 @@ public function testSingleChoiceGrouped()
493505
{
494506
$form = $this->factory->createNamed('name', 'choice', '&a', array(
495507
'choices' => array(
496-
'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
497-
'Group&2' => array('&c' => 'Choice&C'),
508+
'Group&1' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
509+
'Group&2' => array('Choice&C' => '&c'),
498510
),
511+
'choices_as_values' => true,
499512
'multiple' => false,
500513
'expanded' => false,
501514
));
@@ -523,7 +536,8 @@ public function testSingleChoiceGrouped()
523536
public function testMultipleChoice()
524537
{
525538
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
526-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
539+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
540+
'choices_as_values' => true,
527541
'required' => true,
528542
'multiple' => true,
529543
'expanded' => false,
@@ -547,7 +561,8 @@ public function testMultipleChoice()
547561
public function testMultipleChoiceAttributes()
548562
{
549563
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
550-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
564+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
565+
'choices_as_values' => true,
551566
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
552567
'required' => true,
553568
'multiple' => true,
@@ -574,7 +589,8 @@ public function testMultipleChoiceAttributes()
574589
public function testMultipleChoiceSkipsPlaceholder()
575590
{
576591
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
577-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
592+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
593+
'choices_as_values' => true,
578594
'multiple' => true,
579595
'expanded' => false,
580596
'placeholder' => 'Test&Me',
@@ -597,7 +613,8 @@ public function testMultipleChoiceSkipsPlaceholder()
597613
public function testMultipleChoiceNonRequired()
598614
{
599615
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
600-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
616+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
617+
'choices_as_values' => true,
601618
'required' => false,
602619
'multiple' => true,
603620
'expanded' => false,
@@ -620,7 +637,8 @@ public function testMultipleChoiceNonRequired()
620637
public function testSingleChoiceExpanded()
621638
{
622639
$form = $this->factory->createNamed('name', 'choice', '&a', array(
623-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
640+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
641+
'choices_as_values' => true,
624642
'multiple' => false,
625643
'expanded' => true,
626644
));
@@ -655,7 +673,8 @@ public function testSingleChoiceExpanded()
655673
public function testSingleChoiceExpandedWithoutTranslation()
656674
{
657675
$form = $this->factory->createNamed('name', 'choice', '&a', array(
658-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
676+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
677+
'choices_as_values' => true,
659678
'multiple' => false,
660679
'expanded' => true,
661680
'choice_translation_domain' => false,
@@ -691,7 +710,8 @@ public function testSingleChoiceExpandedWithoutTranslation()
691710
public function testSingleChoiceExpandedAttributes()
692711
{
693712
$form = $this->factory->createNamed('name', 'choice', '&a', array(
694-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
713+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
714+
'choices_as_values' => true,
695715
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
696716
'multiple' => false,
697717
'expanded' => true,
@@ -729,7 +749,8 @@ public function testSingleChoiceExpandedAttributes()
729749
public function testSingleChoiceExpandedWithPlaceholder()
730750
{
731751
$form = $this->factory->createNamed('name', 'choice', '&a', array(
732-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
752+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
753+
'choices_as_values' => true,
733754
'multiple' => false,
734755
'expanded' => true,
735756
'placeholder' => 'Test&Me',
@@ -774,7 +795,8 @@ public function testSingleChoiceExpandedWithPlaceholder()
774795
public function testSingleChoiceExpandedWithBooleanValue()
775796
{
776797
$form = $this->factory->createNamed('name', 'choice', true, array(
777-
'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'),
798+
'choices' => array('Choice&A' => '1', 'Choice&B' => '0'),
799+
'choices_as_values' => true,
778800
'multiple' => false,
779801
'expanded' => true,
780802
));
@@ -809,7 +831,8 @@ public function testSingleChoiceExpandedWithBooleanValue()
809831
public function testMultipleChoiceExpanded()
810832
{
811833
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
812-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
834+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
835+
'choices_as_values' => true,
813836
'multiple' => true,
814837
'expanded' => true,
815838
'required' => true,
@@ -854,7 +877,8 @@ public function testMultipleChoiceExpanded()
854877
public function testMultipleChoiceExpandedWithoutTranslation()
855878
{
856879
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
857-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
880+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
881+
'choices_as_values' => true,
858882
'multiple' => true,
859883
'expanded' => true,
860884
'required' => true,
@@ -900,7 +924,8 @@ public function testMultipleChoiceExpandedWithoutTranslation()
900924
public function testMultipleChoiceExpandedAttributes()
901925
{
902926
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
903-
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
927+
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
928+
'choices_as_values' => true,
904929
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
905930
'multiple' => true,
906931
'expanded' => true,

src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,8 @@ public function testCollectionRowWithCustomBlock()
692692
public function testChoiceRowWithCustomBlock()
693693
{
694694
$form = $this->factory->createNamedBuilder('name_c', 'choice', 'a', array(
695-
'choices' => array('a' => 'ChoiceA', 'b' => 'ChoiceB'),
695+
'choices' => array('ChoiceA' => 'a', 'ChoiceB' => 'b'),
696+
'choices_as_values' => true,
696697
'expanded' => true,
697698
))
698699
->getForm();

0 commit comments

Comments
 (0)