Failed Conditions
Pull Request — 2.6 (#7890)
by
unknown
10:05 queued 03:38
created

DDC2182Test::getColumnCollationDeclarationSQL()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 1
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5
class DDC2182Test extends \Doctrine\Tests\OrmFunctionalTestCase
6
{
7
    public function testPassColumnOptionsToJoinColumns()
8
    {
9
        if ($this->_em->getConnection()->getDatabasePlatform()->getName() != 'mysql') {
10
            $this->markTestSkipped("This test is useful for all databases, but designed only for mysql.");
11
        }
12
13
        $sql = $this->_schemaTool->getCreateSchemaSql(
14
            [
15
            $this->_em->getClassMetadata(DDC2182OptionParent::class),
16
            $this->_em->getClassMetadata(DDC2182OptionChild::class),
17
            ]
18
        );
19
20
        $this->assertEquals("CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[0]);
21
        $this->assertEquals("CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[1]);
22
        $this->assertEquals("ALTER TABLE DDC2182OptionChild ADD CONSTRAINT FK_B314D4AD727ACA70 FOREIGN KEY (parent_id) REFERENCES DDC2182OptionParent (id)", $sql[2]);
23
    }
24
}
25
26
/**
27
 * @Entity
28
 * @Table
29
 */
30
class DDC2182OptionParent
31
{
32
    /** @Id @Column(type="integer", options={"unsigned": true}) */
33
    private $id;
0 ignored issues
show
introduced by
The private property $id is not used, and could be removed.
Loading history...
34
}
35
36
/**
37
 * @Entity
38
 * @Table
39
 */
40
class DDC2182OptionChild
41
{
42
    /** @Id @Column */
43
    private $id;
44
45
    /**
46
     * @ManyToOne(targetEntity="DDC2182OptionParent")
47
     * @JoinColumn(referencedColumnName="id")
48
     */
49
    private $parent;
0 ignored issues
show
introduced by
The private property $parent is not used, and could be removed.
Loading history...
50
}
51