Added EntityChoiceList test for group_by
and invalid, deep property paths
This is a common case with optional Entity associations: $user->getGroup()->getName() The property path `group.name` (traversing from the User Entity), when the User is not assigned to a Group, will throw an UnexpectedTypeException. This is caught so that the User can still be listed as an option, just without any nesting.
This commit is contained in:
parent
e6554d6d45
commit
d9b7abb7c7
@ -150,4 +150,30 @@ class EntityChoiceListTest extends DoctrineOrmTestCase
|
||||
'4' => 'Boo!'
|
||||
), $choiceList->getChoices('choices'));
|
||||
}
|
||||
|
||||
public function testGroupByInvalidPropertyPathReturnsFlatChoices()
|
||||
{
|
||||
$item1 = new ItemGroupEntity(1, 'Foo', 'Group1');
|
||||
$item2 = new ItemGroupEntity(2, 'Bar', 'Group1');
|
||||
|
||||
$this->em->persist($item1);
|
||||
$this->em->persist($item2);
|
||||
|
||||
$choiceList = new EntityChoiceList(
|
||||
$this->em,
|
||||
self::ITEM_GROUP_CLASS,
|
||||
'name',
|
||||
null,
|
||||
array(
|
||||
$item1,
|
||||
$item2,
|
||||
),
|
||||
'group_name.child.that.does.not.exist'
|
||||
);
|
||||
|
||||
$this->assertEquals(array(
|
||||
1 => 'Foo',
|
||||
2 => 'Bar'
|
||||
), $choiceList->getChoices('choices'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user