Passed
Pull Request — 2.6 (#7684)
by Grégoire
07:40
created

GH7684::testIssue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 24
rs 9.7666
c 1
b 0
f 0
cc 2
nc 2
nop 0
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\Tests\ORM\Functional\DatabaseDriverTestCase;
9
10
/**
11
 * Verifies that associations/columns with an inline '_id' get named properly
12
 *
13
 * Github issue: 7684
14
 */
15
class GH7684 extends DatabaseDriverTestCase
16
{
17
    public function testIssue() : void
18
    {
19
        if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) {
20
            $this->markTestSkipped('Platform does not support foreign keys.');
21
        }
22
23
        $card = new Table('GH7684_identity_test');
24
        $card->addColumn('id', 'integer');
25
        $card->setPrimaryKey(['id']);
26
27
        $translation = new Table('GH7684_identity_test_assoc');
28
        $translation->addColumn('id', 'integer');
29
        $translation->addColumn('gh7684_identity_test_id', 'integer');
30
        $translation->setPrimaryKey(['id']);
31
        $translation->addForeignKeyConstraint('GH7684_identity_test', ['gh7684_identity_test_id'], ['id']);
32
33
        $metadatas = $this->convertToClassMetadata([$card, $translation]);
34
35
        $this->assertNotNull($metadatas['Gh7684IdentityTest'] ?? null);
36
        $this->assertNotNull($metadatas['Gh7684IdentityTestAssoc'] ?? null);
37
38
        $metadata = $metadatas['Gh7684IdentityTestAssoc'];
39
40
        $metadata->getAssociationMapping('gh7684IdentityTest');
41
    }
42
}
43