1
0
mirror of synced 2024-12-13 22:56:04 +03:00

Merge branch 'DDC-1050'

This commit is contained in:
Benjamin Eberlei 2011-03-03 22:52:13 +01:00
commit 9a33bd083d
3 changed files with 35 additions and 0 deletions

View File

@ -325,6 +325,8 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
if (!$class->discriminatorColumn) {
throw MappingException::missingDiscriminatorColumn($class->name);
}
} else if ($class->isMappedSuperclass && (count($class->discriminatorMap) || $class->discriminatorColumn)) {
throw MappingException::noInheritanceOnMappedSuperClass($class->name);
}
$this->loadedMetadata[$className] = $class;

View File

@ -270,4 +270,9 @@ class MappingException extends \Doctrine\ORM\ORMException
{
return new self("Many-to-many or one-to-many associations are not allowed to be identifier in '$className#$field'.");
}
public static function noInheritanceOnMappedSuperClass($className)
{
return new self("Its not supported to define inheritance information on a mapped superclass '" . $className . "'.");
}
}

View File

@ -149,6 +149,24 @@ class AnnotationDriverTest extends AbstractMappingDriverTest
"mapped superclass 'Doctrine\Tests\ORM\Mapping\InvalidMappedSuperClass#users'");
$usingInvalidMsc = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\UsingInvalidMappedSuperClass');
}
/**
* @group DDC-1050
*/
public function testInvalidMappedSuperClassWithInheritanceInformation()
{
$annotationDriver = $this->_loadDriver();
$em = $this->_getTestEntityManager();
$em->getConfiguration()->setMetadataDriverImpl($annotationDriver);
$factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
$factory->setEntityManager($em);
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException',
"Its not supported to define inheritance information on a mapped ".
"superclass 'Doctrine\Tests\ORM\Mapping\MappedSuperClassInheritence'.");
$usingInvalidMsc = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\MappedSuperClassInheritence');
}
}
/**
@ -180,4 +198,14 @@ class UsingInvalidMappedSuperClass extends InvalidMappedSuperClass
* @Id @Column(type="integer") @GeneratedValue
*/
private $id;
}
/**
* @MappedSuperclass
* @InheritanceType("JOINED")
* @DiscriminatorMap({"test" = "ColumnWithoutType"})
*/
class MappedSuperClassInheritence
{
}