Skip to content

Commit 50bb5d6

Browse files
committed
bug #14887 [Form] Swap new ChoiceView constructor arguments to ease migrating from the deprecated one (nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- [Form] Swap new ChoiceView constructor arguments to ease migrating from the deprecated one | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14193 | License | MIT | Doc PR | - Commits ------- 909d2b9 [Form] Swap new ChoiceView constructor arguments to ease migrating from the deprecated one
2 parents 337dcea + f44bd17 commit 50bb5d6

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Tests/Form/Type/EntityTypeTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function testSetDataToUninitializedEntityWithNonRequired()
134134
'choice_label' => 'name',
135135
));
136136

137-
$this->assertEquals(array(1 => new ChoiceView('Foo', '1', $entity1), 2 => new ChoiceView('Bar', '2', $entity2)), $field->createView()->vars['choices']);
137+
$this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']);
138138
}
139139

140140
public function testSetDataToUninitializedEntityWithNonRequiredToString()
@@ -150,7 +150,7 @@ public function testSetDataToUninitializedEntityWithNonRequiredToString()
150150
'required' => false,
151151
));
152152

153-
$this->assertEquals(array(1 => new ChoiceView('Foo', '1', $entity1), 2 => new ChoiceView('Bar', '2', $entity2)), $field->createView()->vars['choices']);
153+
$this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']);
154154
}
155155

156156
public function testSetDataToUninitializedEntityWithNonRequiredQueryBuilder()
@@ -169,7 +169,7 @@ public function testSetDataToUninitializedEntityWithNonRequiredQueryBuilder()
169169
'query_builder' => $qb,
170170
));
171171

172-
$this->assertEquals(array(1 => new ChoiceView('Foo', '1', $entity1), 2 => new ChoiceView('Bar', '2', $entity2)), $field->createView()->vars['choices']);
172+
$this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']);
173173
}
174174

175175
/**
@@ -513,7 +513,7 @@ public function testOverrideChoices()
513513

514514
$field->submit('2');
515515

516-
$this->assertEquals(array(1 => new ChoiceView('Foo', '1', $entity1), 2 => new ChoiceView('Bar', '2', $entity2)), $field->createView()->vars['choices']);
516+
$this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']);
517517
$this->assertTrue($field->isSynchronized());
518518
$this->assertSame($entity2, $field->getData());
519519
$this->assertSame('2', $field->getViewData());
@@ -541,13 +541,13 @@ public function testGroupByChoices()
541541
$this->assertSame('2', $field->getViewData());
542542
$this->assertEquals(array(
543543
'Group1' => new ChoiceGroupView('Group1', array(
544-
1 => new ChoiceView('Foo', '1', $item1),
545-
2 => new ChoiceView('Bar', '2', $item2),
544+
1 => new ChoiceView($item1, '1', 'Foo'),
545+
2 => new ChoiceView($item2, '2', 'Bar'),
546546
)),
547547
'Group2' => new ChoiceGroupView('Group2', array(
548-
3 => new ChoiceView('Baz', '3', $item3),
548+
3 => new ChoiceView($item3, '3', 'Baz'),
549549
)),
550-
4 => new ChoiceView('Boo!', '4', $item4),
550+
4 => new ChoiceView($item4, '4', 'Boo!'),
551551
), $field->createView()->vars['choices']);
552552
}
553553

@@ -566,8 +566,8 @@ public function testPreferredChoices()
566566
'choice_label' => 'name',
567567
));
568568

569-
$this->assertEquals(array(3 => new ChoiceView('Baz', '3', $entity3), 2 => new ChoiceView('Bar', '2', $entity2)), $field->createView()->vars['preferred_choices']);
570-
$this->assertEquals(array(1 => new ChoiceView('Foo', '1', $entity1)), $field->createView()->vars['choices']);
569+
$this->assertEquals(array(3 => new ChoiceView($entity3, '3', 'Baz'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['preferred_choices']);
570+
$this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo')), $field->createView()->vars['choices']);
571571
}
572572

573573
public function testOverrideChoicesWithPreferredChoices()
@@ -586,8 +586,8 @@ public function testOverrideChoicesWithPreferredChoices()
586586
'choice_label' => 'name',
587587
));
588588

589-
$this->assertEquals(array(3 => new ChoiceView('Baz', '3', $entity3)), $field->createView()->vars['preferred_choices']);
590-
$this->assertEquals(array(2 => new ChoiceView('Bar', '2', $entity2)), $field->createView()->vars['choices']);
589+
$this->assertEquals(array(3 => new ChoiceView($entity3, '3', 'Baz')), $field->createView()->vars['preferred_choices']);
590+
$this->assertEquals(array(2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']);
591591
}
592592

593593
public function testDisallowChoicesThatAreNotIncludedChoicesSingleIdentifier()
@@ -883,7 +883,7 @@ public function testPropertyOption()
883883
'property' => 'name',
884884
));
885885

886-
$this->assertEquals(array(1 => new ChoiceView('Foo', '1', $entity1), 2 => new ChoiceView('Bar', '2', $entity2)), $field->createView()->vars['choices']);
886+
$this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']);
887887
}
888888

889889
protected function createRegistryMock($name, $em)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"symfony/phpunit-bridge": "~2.7",
2424
"symfony/stopwatch": "~2.2",
2525
"symfony/dependency-injection": "~2.2",
26-
"symfony/form": "~2.7",
26+
"symfony/form": "~2.7,>=2.7.1",
2727
"symfony/http-kernel": "~2.2",
2828
"symfony/property-access": "~2.3",
2929
"symfony/security": "~2.2",

0 commit comments

Comments
 (0)