diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index 95d6ad817..7fb780407 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -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; diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index 42b871f1e..6d3ed77d1 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -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 *