1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Schema\Table; |
8
|
|
|
use Doctrine\ORM\Mapping\MappingException; |
9
|
|
|
use Doctrine\Tests\ORM\Functional\DatabaseDriverTestCase; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Verifies that associations/columns with an inline '_id' get named properly |
13
|
|
|
* |
14
|
|
|
* Github issue: 7684 |
15
|
|
|
*/ |
16
|
|
|
class GH7684 extends DatabaseDriverTestCase |
17
|
|
|
{ |
18
|
|
|
public function testIssue() : void |
19
|
|
|
{ |
20
|
|
|
if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { |
21
|
|
|
$this->markTestSkipped('Platform does not support foreign keys.'); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
$card = new Table('partner_identity_card'); |
25
|
|
|
$card->addColumn('id', 'integer'); |
26
|
|
|
$card->setPrimaryKey(['id']); |
27
|
|
|
|
28
|
|
|
$translation = new Table('partner_identity_card_translation'); |
29
|
|
|
$translation->addColumn('id', 'integer'); |
30
|
|
|
$translation->addColumn('partner_identity_card_id', 'integer'); |
31
|
|
|
$translation->setPrimaryKey(['id']); |
32
|
|
|
$translation->addForeignKeyConstraint('partner_identity_card', ['partner_identity_card_id'], ['id']); |
33
|
|
|
|
34
|
|
|
$metadata = $this->convertToClassMetadata([$card, $translation]); |
35
|
|
|
|
36
|
|
|
$this->assertNotNull($metadata['PartnerIdentityCard'] ?? null); |
37
|
|
|
$this->assertNotNull($metadata['PartnerIdentityCardTranslation'] ?? null); |
38
|
|
|
|
39
|
|
|
$partnerIdentityCardTranslation = $metadata['PartnerIdentityCardTranslation']; |
40
|
|
|
|
41
|
|
|
try { |
42
|
|
|
$partnerIdentityCardTranslation->getAssociationMapping('partnerIdentityCard'); |
43
|
|
|
} catch (MappingException $e) { |
44
|
|
|
$this->fail("Failed to generate a associationMapping with an inline '_id'"); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
} |