Skip to content

[Form] add test for ArrayChoiceList handling null #17832

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
Feb 18, 2016
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
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ public function testGetValuesForChoicesEmpty()
$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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class ArrayChoiceListTest extends AbstractChoiceListTest

protected function setUp()
{
parent::setUp();

$this->object = new \stdClass();

parent::setUp();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was broken because it was initialized after getChoices is called. so $this->object was actually null.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should maybe just put it before the call to parent::setUp() instead of removing it and keep using $this->object in getChoices()

}

protected function createChoiceList()
Expand All @@ -34,12 +34,12 @@ protected function createChoiceList()

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');
}

/**
Expand Down