1
0
mirror of synced 2024-12-14 15:16:04 +03:00

[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.

This commit is contained in:
beberlei 2010-03-20 19:23:13 +00:00
parent f78ac41cd8
commit 5018985807

View File

@ -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'));
}
}