Completed
Pull Request — 2.6 (#7684)
by Robert den
06:51
created

GH7684   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A testIssue() 0 24 2
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('GH7684_identity_test');
25
        $card->addColumn('id', 'integer');
26
        $card->setPrimaryKey(['id']);
27
28
        $translation = new Table('GH7684_identity_test_assoc');
29
        $translation->addColumn('id', 'integer');
30
        $translation->addColumn('gh7684_identity_test_id', 'integer');
31
        $translation->setPrimaryKey(['id']);
32
        $translation->addForeignKeyConstraint('GH7684_identity_test', ['gh7684_identity_test_id'], ['id']);
33
 
34
        $metadatas = $this->convertToClassMetadata([$card, $translation]);
35
36
        $this->assertNotNull($metadatas['Gh7684IdentityTest'] ?? null);
37
        $this->assertNotNull($metadatas['Gh7684IdentityTestAssoc'] ?? null);
38
        
39
        $metadata= $metadatas['Gh7684IdentityTestAssoc'];
40
        
41
        $metadata->getAssociationMapping('gh7684IdentityTest');
42
    }
43
}
44
45