2013-05-09 12:10:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
|
|
|
|
|
|
|
use Doctrine\Tests\ORM\Functional\DatabaseDriverTestCase;
|
|
|
|
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
|
|
|
|
|
|
|
class DDC2387Test extends DatabaseDriverTestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @group DDC-2387
|
|
|
|
*/
|
|
|
|
public function testCompositeAssociationKeyDetection()
|
|
|
|
{
|
|
|
|
$product = new \Doctrine\DBAL\Schema\Table('ddc2387_product');
|
|
|
|
$product->addColumn('id', 'integer');
|
2016-12-07 23:33:41 +01:00
|
|
|
$product->setPrimaryKey(['id']);
|
2013-05-09 12:10:37 +02:00
|
|
|
|
|
|
|
$attributes = new \Doctrine\DBAL\Schema\Table('ddc2387_attributes');
|
|
|
|
$attributes->addColumn('product_id', 'integer');
|
|
|
|
$attributes->addColumn('attribute_name', 'string');
|
2016-12-07 23:33:41 +01:00
|
|
|
$attributes->setPrimaryKey(['product_id', 'attribute_name']);
|
|
|
|
$attributes->addForeignKeyConstraint('ddc2387_product', ['product_id'], ['product_id']);
|
2013-05-09 12:10:37 +02:00
|
|
|
|
2016-12-07 23:33:41 +01:00
|
|
|
$metadata = $this->convertToClassMetadata([$product, $attributes], []);
|
2013-05-09 12:10:37 +02:00
|
|
|
|
|
|
|
$this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $metadata['Ddc2387Attributes']->generatorType);
|
|
|
|
$this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_AUTO, $metadata['Ddc2387Product']->generatorType);
|
|
|
|
}
|
|
|
|
}
|