diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index f32ada9a0..54087880a 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -85,7 +85,11 @@ class XmlDriver extends AbstractFileDriver // Evaluate if (isset($xmlRoot->{'discriminator-map'})) { - $metadata->setDiscriminatorMap((array)$xmlRoot->{'discriminator-map'}); + $map = array(); + foreach ($xmlRoot->{'discriminator-map'}->{'discriminator-mapping'} AS $discrMapElement) { + $map[(string)$discrMapElement['value']] = (string)$discrMapElement['class']; + } + $metadata->setDiscriminatorMap($map); } // Evaluate diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index 7e9c78edf..d41e01eed 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -14,4 +14,31 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest { return new XmlDriver(__DIR__ . DIRECTORY_SEPARATOR . 'xml'); } -} \ No newline at end of file + + public function testClassTableInheritanceDiscriminatorMap() + { + $className = 'Doctrine\Tests\ORM\Mapping\CTI'; + $mappingDriver = $this->_loadDriver(); + + $class = new ClassMetadata($className); + $mappingDriver->loadMetadataForClass($className, $class); + + $expectedMap = array( + "foo" => "Doctrine\Tests\ORM\Mapping\CTIFoo", + "bar" => "Doctrine\Tests\ORM\Mapping\CTIBar", + "baz" => "Doctrine\Tests\ORM\Mapping\CTIBaz", + ); + + $this->assertEquals(3, count($class->discriminatorMap)); + $this->assertEquals($expectedMap, $class->discriminatorMap); + } +} + +class CTI +{ + public $id; +} + +class CTIFoo extends CTI {} +class CTIBar extends CTI {} +class CTIBaz extends CTI {} \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml new file mode 100644 index 000000000..9c8c8f98e --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file