From 7cf8d1ae5224a60f435f35a7266af35af33e34a4 Mon Sep 17 00:00:00 2001 From: beberlei Date: Tue, 2 Feb 2010 21:46:39 +0000 Subject: [PATCH] [2.0] DDC-268 Added missing duplicateAssociationMapping() method to MappingException --- lib/Doctrine/ORM/Mapping/MappingException.php | 4 ++++ .../Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php | 11 +++++++++++ 2 files changed, 15 insertions(+) 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