Fix to allow null values in labels array
This commit is contained in:
parent
a22111b913
commit
4e909bd016
@ -261,7 +261,7 @@ class ChoiceList implements ChoiceListInterface
|
|||||||
{
|
{
|
||||||
// Add choices to the nested buckets
|
// Add choices to the nested buckets
|
||||||
foreach ($choices as $group => $choice) {
|
foreach ($choices as $group => $choice) {
|
||||||
if (!isset($labels[$group])) {
|
if (!array_key_exists($group, $labels)) {
|
||||||
throw new \InvalidArgumentException('The structures of the choices and labels array do not match.');
|
throw new \InvalidArgumentException('The structures of the choices and labels array do not match.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,4 +184,20 @@ class ChoiceListTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('A')
|
array('A')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test for pull request: https://github.com/symfony/symfony/pull/5394
|
||||||
|
*/
|
||||||
|
public function testLabelsContainingNull()
|
||||||
|
{
|
||||||
|
$this->list = new ChoiceList(
|
||||||
|
array($this->obj1, $this->obj2),
|
||||||
|
array('A', null)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
array(0 => new ChoiceView($this->obj1, '0', 'A'), 1 => new ChoiceView($this->obj2, '1', null)),
|
||||||
|
$this->list->getRemainingViews()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user