Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'DDC-2148' into 2.2

  • Loading branch information...
commit 200c6fa3b92294d50b84d5d239a7b2339d318b4b 2 parents 37a4582 + 1b5f051
@beberlei beberlei authored
View
2  lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
@@ -1309,6 +1309,8 @@ protected function _validateAndCompleteManyToManyMapping(array $mapping)
'onDelete' => 'CASCADE'));
}
+ $mapping['joinTableColumns'] = array();
+
foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) {
if (empty($joinColumn['name'])) {
$joinColumn['name'] = $sourceShortName . '_id';
View
1  lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php
@@ -73,6 +73,7 @@ private function remapAssociation($classMetadata, $mapping)
$newMapping = $this->resolveTargetEntities[$mapping['targetEntity']];
$newMapping = array_replace_recursive($mapping, $newMapping);
$newMapping['fieldName'] = $mapping['fieldName'];
+
unset($classMetadata->associationMappings[$mapping['fieldName']]);
switch ($mapping['type']) {
View
25 tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php
@@ -60,6 +60,31 @@ public function testResolveTargetEntityListenerCanResolveTargetEntity()
$this->assertSame('Doctrine\Tests\ORM\Tools\ResolveTargetEntity', $meta['oneToMany']['targetEntity']);
$this->assertSame('Doctrine\Tests\ORM\Tools\TargetEntity', $meta['oneToOne']['targetEntity']);
}
+
+ /**
+ * @group DDC-2109
+ */
+ public function testAssertTableColumnsAreNotAddedInManyToMany()
+ {
+ $evm = $this->em->getEventManager();
+ $this->listener->addResolveTargetEntity(
+ 'Doctrine\Tests\ORM\Tools\ResolveTargetInterface',
+ 'Doctrine\Tests\ORM\Tools\ResolveTargetEntity',
+ array()
+ );
+ $this->listener->addResolveTargetEntity(
+ 'Doctrine\Tests\ORM\Tools\TargetInterface',
+ 'Doctrine\Tests\ORM\Tools\TargetEntity',
+ array()
+ );
+
+ $evm->addEventListener(Events::loadClassMetadata, $this->listener);
+ $cm = $this->factory->getMetadataFor('Doctrine\Tests\ORM\Tools\ResolveTargetEntity');
+ $meta = $cm->associationMappings['manyToMany'];
+
+ $this->assertSame('Doctrine\Tests\ORM\Tools\TargetEntity', $meta['targetEntity']);
+ $this->assertEquals(array('resolvetargetentity_id', 'targetinterface_id'), $meta['joinTableColumns']);
+ }
}
interface ResolveTargetInterface
Please sign in to comment.
Something went wrong with that request. Please try again.