Permalink
Browse files

Merge branch 'DDC-2148' into 2.2

  • Loading branch information...
2 parents 37a4582 + 1b5f051 commit 200c6fa3b92294d50b84d5d239a7b2339d318b4b @beberlei beberlei committed Nov 21, 2012
@@ -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';
@@ -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']) {
@@ -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

0 comments on commit 200c6fa

Please sign in to comment.