Fix DDC-2079
This commit is contained in:
parent
56e96793c0
commit
fb467a1196
@ -1084,17 +1084,23 @@ public function __construct()
|
||||
$lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'JoinTable(' . implode(', ', $joinTable) . ',';
|
||||
$lines[] = $this->spaces . ' * joinColumns={';
|
||||
|
||||
$joinColumnsLines = array();
|
||||
|
||||
foreach ($associationMapping['joinTable']['joinColumns'] as $joinColumn) {
|
||||
$lines[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn);
|
||||
$joinColumnsLines[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn);
|
||||
}
|
||||
|
||||
$lines[] = implode(",". PHP_EOL, $joinColumnsLines);
|
||||
$lines[] = $this->spaces . ' * },';
|
||||
$lines[] = $this->spaces . ' * inverseJoinColumns={';
|
||||
|
||||
$inverseJoinColumnsLines = array();
|
||||
|
||||
foreach ($associationMapping['joinTable']['inverseJoinColumns'] as $joinColumn) {
|
||||
$lines[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn);
|
||||
$inverseJoinColumnsLines[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn);
|
||||
}
|
||||
|
||||
$lines[] = implode(",". PHP_EOL, $inverseJoinColumnsLines);
|
||||
$lines[] = $this->spaces . ' * }';
|
||||
$lines[] = $this->spaces . ' * )';
|
||||
}
|
||||
|
@ -278,6 +278,50 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertContains('@SequenceGenerator(sequenceName="DDC1784_ID_SEQ", allocationSize=1, initialValue=2)', $docComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2079
|
||||
*/
|
||||
public function testGenerateEntityWithMultipleInverseJoinColumns()
|
||||
{
|
||||
$metadata = new ClassMetadataInfo($this->_namespace . '\DDC2079Entity');
|
||||
$metadata->namespace = $this->_namespace;
|
||||
$metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
|
||||
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE);
|
||||
$metadata->mapManyToMany(array(
|
||||
'fieldName' => 'centroCustos',
|
||||
'targetEntity' => 'DDC2079CentroCusto',
|
||||
'joinTable' => array(
|
||||
'name' => 'unidade_centro_custo',
|
||||
'joinColumns' => array(
|
||||
array('name' => 'idorcamento', 'referencedColumnName' => 'idorcamento'),
|
||||
array('name' => 'idunidade', 'referencedColumnName' => 'idunidade')
|
||||
),
|
||||
'inverseJoinColumns' => array(
|
||||
array('name' => 'idcentrocusto', 'referencedColumnName' => 'idcentrocusto'),
|
||||
array('name' => 'idpais', 'referencedColumnName' => 'idpais'),
|
||||
),
|
||||
),
|
||||
));
|
||||
$this->_generator->writeEntityClass($metadata, $this->_tmpDir);
|
||||
|
||||
$filename = $this->_tmpDir . DIRECTORY_SEPARATOR
|
||||
. $this->_namespace . DIRECTORY_SEPARATOR . 'DDC2079Entity.php';
|
||||
|
||||
$this->assertFileExists($filename);
|
||||
require_once $filename;
|
||||
|
||||
$propertu = new \ReflectionProperty($metadata->name, 'centroCustos');
|
||||
$docComment = $propertu->getDocComment();
|
||||
|
||||
//joinColumns
|
||||
$this->assertContains('@JoinColumn(name="idorcamento", referencedColumnName="idorcamento"),', $docComment);
|
||||
$this->assertContains('@JoinColumn(name="idunidade", referencedColumnName="idunidade")', $docComment);
|
||||
//inverseJoinColumns
|
||||
$this->assertContains('@JoinColumn(name="idcentrocusto", referencedColumnName="idcentrocusto"),', $docComment);
|
||||
$this->assertContains('@JoinColumn(name="idpais", referencedColumnName="idpais")', $docComment);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getEntityTypeAliasDataProvider
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user