diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index 8228ba1ca..5785ccf2c 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -216,7 +216,7 @@ class XmlDriver extends AbstractFileDriver $associationIds = array(); foreach ($xmlRoot->id as $idElement) { if ((bool)$idElement['association-key'] == true) { - $associationIds[(string)$idElement['fieldName']] = true; + $associationIds[(string)$idElement['name']] = true; continue; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index 8308ea260..9ba8748f4 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -33,6 +33,24 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest $this->assertEquals($expectedMap, $class->discriminatorMap); } + public function testIdentifierWithAssociationKey() + { + $driver = $this->_loadDriver(); + $em = $this->_getTestEntityManager(); + $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + + $em->getConfiguration()->setMetadataDriverImpl($driver); + $factory->setEntityManager($em); + + $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC117\DDC117Translation'); + + $this->assertEquals(array('language', 'article'), $class->identifier); + $this->assertArrayHasKey('article', $class->associationMappings); + + $this->assertArrayHasKey('id', $class->associationMappings['article']); + $this->assertTrue($class->associationMappings['article']['id']); + } + /** * @param string $xmlMappingFile * @dataProvider dataValidSchema diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml new file mode 100644 index 000000000..c0df0886a --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file