[DDC-1132] Fix many to many table detection.
This commit is contained in:
parent
41b3a372d3
commit
f09d299660
1 changed files with 34 additions and 1 deletions
|
@ -104,9 +104,42 @@ class DatabaseDriverTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||||
$this->assertArrayHasKey('user', $metadatas['CmsGroups']->associationMappings);
|
$this->assertArrayHasKey('user', $metadatas['CmsGroups']->associationMappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testIgnoreManyToManyTableWithoutFurtherForeignKeyDetails()
|
||||||
|
{
|
||||||
|
$tableB = new \Doctrine\DBAL\Schema\Table("dbdriver_bar");
|
||||||
|
$tableB->addColumn('id', 'integer');
|
||||||
|
$tableB->setPrimaryKey(array('id'));
|
||||||
|
|
||||||
|
$tableA = new \Doctrine\DBAL\Schema\Table("dbdriver_baz");
|
||||||
|
$tableA->addColumn('id', 'integer');
|
||||||
|
$tableA->setPrimaryKey(array('id'));
|
||||||
|
|
||||||
|
$tableMany = new \Doctrine\DBAL\Schema\Table("dbdriver_bar_baz");
|
||||||
|
$tableMany->addColumn('bar_id', 'integer');
|
||||||
|
$tableMany->addColumn('baz_id', 'integer');
|
||||||
|
$tableMany->addForeignKeyConstraint('dbdriver_bar', array('bar_id'), array('id'));
|
||||||
|
|
||||||
|
$metadatas = $this->convertToClassMetadata(array($tableA, $tableB), array($tableMany));
|
||||||
|
|
||||||
|
$this->assertEquals(0, count($metadatas['DbdriverBaz']->associationMappings), "no association mappings should be detected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function convertToClassMetadata(array $entityTables, array $manyTables = array())
|
||||||
|
{
|
||||||
|
$driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($this->_sm);
|
||||||
|
$driver->setTables($entityTables, $manyTables);
|
||||||
|
|
||||||
|
$metadatas = array();
|
||||||
|
foreach ($driver->getAllClassNames() AS $className) {
|
||||||
|
$class = new ClassMetadataInfo($className);
|
||||||
|
$driver->loadMetadataForClass($className, $class);
|
||||||
|
$metadatas[$className] = $class;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $metadatas;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param string $className
|
* @param string $className
|
||||||
* @return ClassMetadata
|
* @return ClassMetadata
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue