1
0
mirror of synced 2025-01-09 18:47:10 +03:00

Fix XmlDriver to accept embeddables

This commit is contained in:
Jan Kramer 2013-12-07 16:40:54 +01:00
parent 928c32d616
commit fbb7b5ad8e
2 changed files with 29 additions and 1 deletions

View File

@ -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;

View File

@ -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
*