diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index fbd834ae8..8f50c15b5 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -152,6 +152,10 @@ class MappingException extends \Doctrine\ORM\ORMException return new self('Property "'.$fieldName.'" in "'.$entity.'" was already declared, but it must be declared only once'); } + public static function duplicateAssociationMapping($entity, $fieldName) { + return new self('Property "'.$fieldName.'" in "'.$entity.'" was already declared, but it must be declared only once'); + } + public static function singleIdNotAllowedOnCompositePrimaryKey($entity) { return new self('Single id is not allowed on composite primary key in entity '.$entity); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index ad4723425..728d0554f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -137,4 +137,15 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); $cm->getSingleIdentifierFieldName(); } + + public function testDuplicateAssociationMappingException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $a1 = new \Doctrine\ORM\Mapping\OneToOneMapping(array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'joinColumns' => array())); + $a2 = new \Doctrine\ORM\Mapping\OneToOneMapping(array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'joinColumns' => array())); + + $cm->addAssociationMapping($a1); + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->addAssociationMapping($a2); + } } \ No newline at end of file