Merge pull request #1540 from pantelm/master
[DDC-3711] Correct Error on manyToMany with composite primary key + add Tests
This commit is contained in:
commit
49bb687aaf
@ -515,9 +515,8 @@ class YamlDriver extends FileDriver
|
||||
if ( ! isset($joinColumnElement['name'])) {
|
||||
$joinColumnElement['name'] = $joinColumnName;
|
||||
}
|
||||
$joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumnElement);
|
||||
}
|
||||
|
||||
$joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumnElement);
|
||||
}
|
||||
|
||||
if (isset($joinTableElement['inverseJoinColumns'])) {
|
||||
@ -525,9 +524,8 @@ class YamlDriver extends FileDriver
|
||||
if ( ! isset($joinColumnElement['name'])) {
|
||||
$joinColumnElement['name'] = $joinColumnName;
|
||||
}
|
||||
$joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumnElement);
|
||||
}
|
||||
|
||||
$joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumnElement);
|
||||
}
|
||||
|
||||
$mapping['joinTable'] = $joinTable;
|
||||
|
78
tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php
Normal file
78
tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Marc Pantel <pantel.m@gmail.com>
|
||||
*/
|
||||
namespace Doctrine\Tests\Models\DDC3711;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class DDC3711EntityA
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $id1;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $id2;
|
||||
|
||||
/**
|
||||
* @var ArrayCollection
|
||||
*/
|
||||
private $entityB;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId1()
|
||||
{
|
||||
return $this->id1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id1
|
||||
*/
|
||||
public function setId1($id1)
|
||||
{
|
||||
$this->id1 = $id1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId2()
|
||||
{
|
||||
return $this->id2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id2
|
||||
*/
|
||||
public function setId2($id2)
|
||||
{
|
||||
$this->id2 = $id2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getEntityB()
|
||||
{
|
||||
return $this->entityB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayCollection $entityB
|
||||
*
|
||||
* @return DDC3711EntityA
|
||||
*/
|
||||
public function addEntityB($entityB)
|
||||
{
|
||||
$this->entityB[] = $entityB;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
75
tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php
Normal file
75
tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Marc Pantel <pantel.m@gmail.com>
|
||||
*/
|
||||
namespace Doctrine\Tests\Models\DDC3711;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class DDC3711EntityB
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $id1;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $id2;
|
||||
|
||||
/**
|
||||
* @var ArrayCollection
|
||||
*/
|
||||
private $entityA;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId1()
|
||||
{
|
||||
return $this->id1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id1
|
||||
*/
|
||||
public function setId1($id1)
|
||||
{
|
||||
$this->id1 = $id1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId2()
|
||||
{
|
||||
return $this->id2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id2
|
||||
*/
|
||||
public function setId2($id2)
|
||||
{
|
||||
$this->id2 = $id2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getEntityA()
|
||||
{
|
||||
return $this->entityA;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayCollection $entityA
|
||||
*/
|
||||
public function addEntityA($entityA)
|
||||
{
|
||||
$this->entityA[] = $entityA;
|
||||
}
|
||||
|
||||
}
|
30
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php
Normal file
30
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Marc Pantel <pantel.m@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\Tests\ORM\Mapping\YamlMappingDriverTest;
|
||||
|
||||
class DDC3711Test extends YamlMappingDriverTest
|
||||
{
|
||||
public function testCompositeKeyForJoinTableInManyToManyCreation()
|
||||
{
|
||||
$yamlDriver = $this->_loadDriver();
|
||||
|
||||
$em = $this->_getTestEntityManager();
|
||||
$em->getConfiguration()->setMetadataDriverImpl($yamlDriver);
|
||||
$factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
|
||||
$factory->setEntityManager($em);
|
||||
|
||||
$entityA = new ClassMetadata('Doctrine\Tests\Models\DDC3711\DDC3711EntityA');
|
||||
$entityA = $factory->getMetadataFor('Doctrine\Tests\Models\DDC3711\DDC3711EntityA');
|
||||
|
||||
$this->assertEquals(array('link_a_id1' => "id1", 'link_a_id2' => "id2"), $entityA->associationMappings['entityB']['relationToSourceKeyColumns']);
|
||||
$this->assertEquals(array('link_b_id1' => "id1", 'link_b_id2' => "id2"), $entityA->associationMappings['entityB']['relationToTargetKeyColumns']);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
Doctrine\Tests\Models\DDC3711\DDC3711EntityA:
|
||||
type: entity
|
||||
table: ddc3711.entityA
|
||||
id:
|
||||
id1:
|
||||
type: int
|
||||
id2:
|
||||
type: int
|
||||
manyToMany:
|
||||
entityB:
|
||||
targetEntity: Doctrine\Tests\Models\DDC3711\DDC3711EntityB
|
||||
joinTable:
|
||||
name: link
|
||||
joinColumns:
|
||||
link_a_id1:
|
||||
referencedColumnName: id1
|
||||
link_a_id2:
|
||||
referencedColumnName: id2
|
||||
inverseJoinColumns:
|
||||
link_b_id1:
|
||||
referencedColumnName: id1
|
||||
link_b_id2:
|
||||
referencedColumnName: id2
|
@ -0,0 +1,8 @@
|
||||
Doctrine\Tests\Models\DDC3711\DDC3711EntityB:
|
||||
type: entity
|
||||
table: ddc3711.entityB
|
||||
id:
|
||||
id1:
|
||||
type: int
|
||||
id2:
|
||||
type: int
|
Loading…
x
Reference in New Issue
Block a user