Fix XmlDriver to accept embeddables
This commit is contained in:
parent
928c32d616
commit
fbb7b5ad8e
@ -754,6 +754,11 @@ class XmlDriver extends FileDriver
|
||||
$className = (string)$mappedSuperClass['name'];
|
||||
$result[$className] = $mappedSuperClass;
|
||||
}
|
||||
} else if (isset($xmlElement->embeddable)) {
|
||||
foreach ($xmlElement->embeddable as $embeddableElement) {
|
||||
$embeddableName = (string) $embeddableElement['name'];
|
||||
$result[$embeddableName] = $embeddableElement;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace Doctrine\Tests\ORM\Mapping;
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadata,
|
||||
Doctrine\ORM\Mapping\ClassMetadataFactory,
|
||||
Doctrine\ORM\Mapping\Driver\XmlDriver,
|
||||
Doctrine\ORM\Mapping\Driver\YamlDriver;
|
||||
|
||||
@ -38,7 +39,7 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest
|
||||
{
|
||||
$driver = $this->_loadDriver();
|
||||
$em = $this->_getTestEntityManager();
|
||||
$factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
|
||||
$factory = new ClassMetadataFactory();
|
||||
|
||||
$em->getConfiguration()->setMetadataDriverImpl($driver);
|
||||
$factory->setEntityManager($em);
|
||||
@ -52,6 +53,28 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest
|
||||
$this->assertTrue($class->associationMappings['article']['id']);
|
||||
}
|
||||
|
||||
public function testEmbeddableMapping()
|
||||
{
|
||||
$class = $this->createClassMetadata('Doctrine\Tests\Models\ValueObjects\Name');
|
||||
|
||||
$this->assertEquals(true, $class->isEmbeddedClass);
|
||||
}
|
||||
|
||||
public function testEmbeddedMapping()
|
||||
{
|
||||
$class = $this->createClassMetadata('Doctrine\Tests\Models\ValueObjects\Person');
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'name' => array(
|
||||
'class' => 'Doctrine\Tests\Models\ValueObjects\Name',
|
||||
'columnPrefix' => 'nm_'
|
||||
)
|
||||
),
|
||||
$class->embeddedClasses
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1468
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user