1
0
mirror of synced 2024-12-13 22:56:04 +03:00

Merge pull request #488 from FabioBatSilva/DDC-2079

Fix DDC-2079
This commit is contained in:
Guilherme Blanco 2012-10-20 19:59:58 -07:00
commit 2c0feb2a46
2 changed files with 52 additions and 2 deletions

View File

@ -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 . ' * )';
}

View File

@ -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;
$property = new \ReflectionProperty($metadata->name, 'centroCustos');
$docComment = $property->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
*