Skip to content

[Form] Fix missing choices_as_values=true in tests #16708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 51 additions & 26 deletions src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ public function testCheckboxWithValue()
public function testSingleChoice()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'multiple' => false,
'expanded' => false,
));
Expand All @@ -234,7 +235,8 @@ public function testSingleChoice()
public function testSingleChoiceWithoutTranslation()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'multiple' => false,
'expanded' => false,
'choice_translation_domain' => false,
Expand All @@ -257,7 +259,8 @@ public function testSingleChoiceWithoutTranslation()
public function testSingleChoiceAttributes()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
'multiple' => false,
'expanded' => false,
Expand All @@ -282,7 +285,8 @@ public function testSingleChoiceAttributes()
public function testSingleChoiceWithPreferred()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'preferred_choices' => array('&b'),
'multiple' => false,
'expanded' => false,
Expand All @@ -306,7 +310,8 @@ public function testSingleChoiceWithPreferred()
public function testSingleChoiceWithPreferredAndNoSeparator()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'preferred_choices' => array('&b'),
'multiple' => false,
'expanded' => false,
Expand All @@ -329,7 +334,8 @@ public function testSingleChoiceWithPreferredAndNoSeparator()
public function testSingleChoiceWithPreferredAndBlankSeparator()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'preferred_choices' => array('&b'),
'multiple' => false,
'expanded' => false,
Expand All @@ -353,7 +359,8 @@ public function testSingleChoiceWithPreferredAndBlankSeparator()
public function testChoiceWithOnlyPreferred()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'preferred_choices' => array('&a', '&b'),
'multiple' => false,
'expanded' => false,
Expand All @@ -370,7 +377,8 @@ public function testChoiceWithOnlyPreferred()
public function testSingleChoiceNonRequired()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'required' => false,
'multiple' => false,
'expanded' => false,
Expand All @@ -394,7 +402,8 @@ public function testSingleChoiceNonRequired()
public function testSingleChoiceNonRequiredNoneSelected()
{
$form = $this->factory->createNamed('name', 'choice', null, array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'required' => false,
'multiple' => false,
'expanded' => false,
Expand All @@ -418,7 +427,8 @@ public function testSingleChoiceNonRequiredNoneSelected()
public function testSingleChoiceNonRequiredWithPlaceholder()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'multiple' => false,
'expanded' => false,
'required' => false,
Expand All @@ -443,7 +453,8 @@ public function testSingleChoiceNonRequiredWithPlaceholder()
public function testSingleChoiceRequiredWithPlaceholder()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'required' => true,
'multiple' => false,
'expanded' => false,
Expand All @@ -468,7 +479,8 @@ public function testSingleChoiceRequiredWithPlaceholder()
public function testSingleChoiceRequiredWithPlaceholderViaView()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'required' => true,
'multiple' => false,
'expanded' => false,
Expand All @@ -493,9 +505,10 @@ public function testSingleChoiceGrouped()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array(
'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'Group&2' => array('&c' => 'Choice&C'),
'Group&1' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'Group&2' => array('Choice&C' => '&c'),
),
'choices_as_values' => true,
'multiple' => false,
'expanded' => false,
));
Expand Down Expand Up @@ -523,7 +536,8 @@ public function testSingleChoiceGrouped()
public function testMultipleChoice()
{
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'required' => true,
'multiple' => true,
'expanded' => false,
Expand All @@ -547,7 +561,8 @@ public function testMultipleChoice()
public function testMultipleChoiceAttributes()
{
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
'required' => true,
'multiple' => true,
Expand All @@ -574,7 +589,8 @@ public function testMultipleChoiceAttributes()
public function testMultipleChoiceSkipsPlaceholder()
{
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'multiple' => true,
'expanded' => false,
'placeholder' => 'Test&Me',
Expand All @@ -597,7 +613,8 @@ public function testMultipleChoiceSkipsPlaceholder()
public function testMultipleChoiceNonRequired()
{
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'required' => false,
'multiple' => true,
'expanded' => false,
Expand All @@ -620,7 +637,8 @@ public function testMultipleChoiceNonRequired()
public function testSingleChoiceExpanded()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'multiple' => false,
'expanded' => true,
));
Expand Down Expand Up @@ -655,7 +673,8 @@ public function testSingleChoiceExpanded()
public function testSingleChoiceExpandedWithoutTranslation()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'multiple' => false,
'expanded' => true,
'choice_translation_domain' => false,
Expand Down Expand Up @@ -691,7 +710,8 @@ public function testSingleChoiceExpandedWithoutTranslation()
public function testSingleChoiceExpandedAttributes()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
'multiple' => false,
'expanded' => true,
Expand Down Expand Up @@ -729,7 +749,8 @@ public function testSingleChoiceExpandedAttributes()
public function testSingleChoiceExpandedWithPlaceholder()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choices_as_values' => true,
'multiple' => false,
'expanded' => true,
'placeholder' => 'Test&Me',
Expand Down Expand Up @@ -774,7 +795,8 @@ public function testSingleChoiceExpandedWithPlaceholder()
public function testSingleChoiceExpandedWithBooleanValue()
{
$form = $this->factory->createNamed('name', 'choice', true, array(
'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'),
'choices' => array('Choice&A' => '1', 'Choice&B' => '0'),
'choices_as_values' => true,
'multiple' => false,
'expanded' => true,
));
Expand Down Expand Up @@ -809,7 +831,8 @@ public function testSingleChoiceExpandedWithBooleanValue()
public function testMultipleChoiceExpanded()
{
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
'choices_as_values' => true,
'multiple' => true,
'expanded' => true,
'required' => true,
Expand Down Expand Up @@ -854,7 +877,8 @@ public function testMultipleChoiceExpanded()
public function testMultipleChoiceExpandedWithoutTranslation()
{
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
'choices_as_values' => true,
'multiple' => true,
'expanded' => true,
'required' => true,
Expand Down Expand Up @@ -900,7 +924,8 @@ public function testMultipleChoiceExpandedWithoutTranslation()
public function testMultipleChoiceExpandedAttributes()
{
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
'choices_as_values' => true,
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
'multiple' => true,
'expanded' => true,
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,8 @@ public function testCollectionRowWithCustomBlock()
public function testChoiceRowWithCustomBlock()
{
$form = $this->factory->createNamedBuilder('name_c', 'choice', 'a', array(
'choices' => array('a' => 'ChoiceA', 'b' => 'ChoiceB'),
'choices' => array('ChoiceA' => 'a', 'ChoiceB' => 'b'),
'choices_as_values' => true,
'expanded' => true,
))
->getForm();
Expand Down
Loading