Permalink
Browse files

Throw exception if target entity is not found.

  • Loading branch information...
1 parent dba8360 commit 3aea203b9ca77df65f55f036080a9af653194cbf @beberlei beberlei committed Oct 22, 2011
@@ -134,8 +134,8 @@ protected function _validateAndCompleteAssociationMapping(array $mapping)
{
$mapping = parent::_validateAndCompleteAssociationMapping($mapping);
- if ( ! class_exists($mapping['targetEntity']) ) {
- #throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']);
+ if ( ! \Doctrine\Common\ClassLoader::classExists($mapping['targetEntity']) ) {
@juzna
juzna Dec 23, 2011 Contributor

After this commit, my app stopped working completely, because \Doctrine\Common\ClassLoader::classExists doesn't properly supports all class loaders

+ throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']);
}
return $mapping;
@@ -482,4 +482,15 @@ public function testLifecycleCallbackNotFound()
$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');
}
+
+ /**
+ * @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'));
+ }
}

0 comments on commit 3aea203

Please sign in to comment.