From 00e38198b7859f38ab87405d13b4cffda8619461 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 17 Feb 2016 20:31:02 +0100 Subject: [PATCH] [Form] add test for ArrayChoiceList handling null --- .../Form/Tests/ChoiceList/AbstractChoiceListTest.php | 7 +++++++ .../Form/Tests/ChoiceList/ArrayChoiceListTest.php | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php index 958bb66d50..08e4285f0c 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php @@ -209,6 +209,13 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase $this->assertSame(array(), $this->list->getValuesForChoices(array())); } + public function testGetChoicesForValuesWithNull() + { + $values = $this->list->getValuesForChoices(array(null)); + + $this->assertNotEmpty($this->list->getChoicesForValues($values)); + } + /** * @return \Symfony\Component\Form\ChoiceList\ChoiceListInterface */ diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php index 9ea5f631a1..f054fd70c0 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php @@ -22,9 +22,9 @@ class ArrayChoiceListTest extends AbstractChoiceListTest protected function setUp() { - parent::setUp(); - $this->object = new \stdClass(); + + parent::setUp(); } protected function createChoiceList() @@ -34,12 +34,12 @@ class ArrayChoiceListTest extends AbstractChoiceListTest protected function getChoices() { - return array(0, 1, '1', 'a', false, true, $this->object); + return array(0, 1, '1', 'a', false, true, $this->object, null); } protected function getValues() { - return array('0', '1', '2', '3', '4', '5', '6'); + return array('0', '1', '2', '3', '4', '5', '6', '7'); } /**