fixed entity choice list BC break
This commit is contained in:
parent
0fa9e4cb69
commit
231e79ce0f
@ -103,7 +103,7 @@ class EntityChoiceList extends ArrayChoiceList
|
||||
// displaying entities as strings
|
||||
if ($property) {
|
||||
$this->propertyPath = new PropertyPath($property);
|
||||
} elseif (!method_exists($this->class, '__toString')) {
|
||||
} elseif (!method_exists($this->classMetadata->getName(), '__toString')) {
|
||||
// Otherwise expect a __toString() method in the entity
|
||||
throw new FormException('Entities passed to the choice field must have a "__toString()" method defined (or you can also override the "property" option).');
|
||||
}
|
||||
|
@ -196,4 +196,24 @@ class EntityChoiceListTest extends DoctrineOrmTestCase
|
||||
2 => 'Bar'
|
||||
), $choiceList->getChoices('choices'));
|
||||
}
|
||||
|
||||
public function testPossibleToProviceShorthandEntityName()
|
||||
{
|
||||
$shorthandName = 'FooBarBundle:Bar';
|
||||
|
||||
$metadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
|
||||
$metadata->expects($this->any())->method('getName')->will($this->returnValue('Symfony\Tests\Bridge\Doctrine\Fixtures\SingleIdentEntity'));
|
||||
|
||||
$em = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
|
||||
$em->expects($this->once())->method('getClassMetaData')->with($shorthandName)->will($this->returnValue($metadata));
|
||||
|
||||
$choiceList = new EntityChoiceList(
|
||||
$em,
|
||||
$shorthandName,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user