From 5018985807c1b025aea8b461d48d39149612f0cd Mon Sep 17 00:00:00 2001 From: beberlei Date: Sat, 20 Mar 2010 19:23:13 +0000 Subject: [PATCH] [2.0] DDC-239 - Added several new mapping validations for duplicate association/field and or column name definitions, and in combination with the discriminator column name. --- .../Tests/ORM/Mapping/ClassMetadataTest.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 1efd452f3..11fb49948 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -166,4 +166,49 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); $cm->addAssociationMapping($a2); } + + public function testDuplicateColumnName_ThrowsMappingException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->mapField(array('fieldName' => 'username', 'columnName' => 'name')); + } + + public function testDuplicateColumnName_DiscriminatorColumn_ThrowsMappingException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->setDiscriminatorColumn(array('name' => 'name')); + } + + public function testDuplicateColumnName_DiscriminatorColumn2_ThrowsMappingException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->setDiscriminatorColumn(array('name' => 'name')); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); + } + + public function testDuplicateFieldAndAssocationMapping1_ThrowsException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->mapOneToOne(array('fieldName' => 'name', 'targetEntity' => 'CmsUser')); + } + + public function testDuplicateFieldAndAssocationMapping2_ThrowsException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->mapOneToOne(array('fieldName' => 'name', 'targetEntity' => 'CmsUser')); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); + } } \ No newline at end of file