Throw exception if target entity is not found.
This commit is contained in:
parent
dba8360166
commit
3aea203b9c
@ -134,8 +134,8 @@ class ClassMetadata extends ClassMetadataInfo
|
|||||||
{
|
{
|
||||||
$mapping = parent::_validateAndCompleteAssociationMapping($mapping);
|
$mapping = parent::_validateAndCompleteAssociationMapping($mapping);
|
||||||
|
|
||||||
if ( ! class_exists($mapping['targetEntity']) ) {
|
if ( ! \Doctrine\Common\ClassLoader::classExists($mapping['targetEntity']) ) {
|
||||||
#throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']);
|
throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $mapping;
|
return $mapping;
|
||||||
|
@ -482,4 +482,15 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "Entity 'Doctrine\Tests\Models\CMS\CmsUser' has no method 'notfound' to be registered as lifecycle callback.");
|
$this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "Entity 'Doctrine\Tests\Models\CMS\CmsUser' has no method 'notfound' to be registered as lifecycle callback.");
|
||||||
$cm->addLifecycleCallback('notfound', 'postLoad');
|
$cm->addLifecycleCallback('notfound', 'postLoad');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group ImproveErrorMessages
|
||||||
|
*/
|
||||||
|
public function testTargetEntityNotFound()
|
||||||
|
{
|
||||||
|
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
||||||
|
|
||||||
|
$this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "The target-entity Doctrine\Tests\Models\CMS\UnknownClass cannot be found in 'Doctrine\Tests\Models\CMS\CmsUser#address'.");
|
||||||
|
$cm->mapManyToOne(array('fieldName' => 'address', 'targetEntity' => 'UnknownClass'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user