8000 minor #17832 [Form] add test for ArrayChoiceList handling null (Tobion) · symfony/symfony@6cc7e2e · GitHub
[go: up one dir, main page]

Skip to content

Commit 6cc7e2e

Browse files
committed
minor #17832 [Form] add test for ArrayChoiceList handling null (Tobion)
This PR was merged into the 2.7 branch. Discussion ---------- [Form] add test for ArrayChoiceList handling null | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - I found this bug but then realised that it was already fixed in #17511. So this just adds a test. Commits ------- 00e3819 [Form] add test for ArrayChoiceList handling null
2 parents d3c55cb + 00e3819 commit 6cc7e2e

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,13 @@ public function testGetValuesForChoicesEmpty()
209209
$this->assertSame(array(), $this->list->getValuesForChoices(array()));
210210
}
211211

212+
public function testGetChoicesForValuesWithNull()
213+
{
214+
$values = $this->list->getValuesForChoices(array(null));
215+
216+
$this->assertNotEmpty($this->list->getChoicesForValues($values));
217+
}
218+
212219
/**
213220
* @return \Symfony\Component\Form\ChoiceList\ChoiceListInterface
214221
*/

src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class ArrayChoiceListTest extends AbstractChoiceListTest
2222

2323
protected function setUp()
2424
{
25-
parent::setUp();
26-
2725
$this->object = new \stdClass();
26+
27+
parent::setUp();
2828
}
2929

3030
protected function createChoiceList()
@@ -34,12 +34,12 @@ protected function createChoiceList()
3434

3535
protected function getChoices()
3636
{
37-
72DE return array(0, 1, '1', 'a', false, true, $this->object);
37+
return array(0, 1, '1', 'a', false, true, $this->object, null);
3838
}
3939

4040
protected function getValues()
4141
{
42-
return array('0', '1', '2', '3', '4', '5', '6');
42+
return array('0', '1', '2', '3', '4', '5', '6', '7');
4343
}
4444

4545
/**

0 commit comments

Comments
 (0)
0