Skip to content

Commit f84beb4

Browse files
minor #16708 [Form] Fix missing choices_as_values=true in tests (nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- [Form] Fix missing choices_as_values=true in tests | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 2a16e87 [Form] Fix missing choices_as_values=true in tests
2 parents ff582b8 + 2a16e87 commit f84beb4

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy