Failed Conditions
Push — master ( 6d428c...2a5864 )
by Marco
165:30 queued 100:26
created

DDC6499Test::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\Tests\Functional\Ticket;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\Tests\OrmFunctionalTestCase;
7
8
/**
9
 * @group #6499
10
 *
11
 *
12
 * Specifically, DDC6499B has a dependency on DDC6499A, and DDC6499A
13
 * has a dependency on DDC6499B. Since DDC6499A#b is not nullable,
14
 * the DDC6499B should be inserted first.
15
 */
16
class DDC6499Test extends OrmFunctionalTestCase
17
{
18
    /**
19
     * {@inheritDoc}
20
     */
21
    protected function setUp() : void
22
    {
23
        parent::setUp();
24
25
        $this->_schemaTool->createSchema([
26
            $this->_em->getClassMetadata(DDC6499A::class),
27
            $this->_em->getClassMetadata(DDC6499B::class),
28
        ]);
29
    }
30
31
    /**
32
     * {@inheritDoc}
33
     */
34
    protected function tearDown() : void
35
    {
36
        parent::tearDown();
37
38
        $this->_schemaTool->dropSchema([
39
            $this->_em->getClassMetadata(DDC6499A::class),
40
            $this->_em->getClassMetadata(DDC6499B::class),
41
        ]);
42
    }
43
44 View Code Duplication
    public function testIssue() : void
45
    {
46
        $b = new DDC6499B();
47
        $a = new DDC6499A();
48
49
        $this->_em->persist($a);
50
51
        $a->b = $b;
52
53
        $this->_em->persist($b);
54
55
        $this->_em->flush();
56
57
        self::assertInternalType('integer', $a->id);
58
        self::assertInternalType('integer', $b->id);
59
    }
60
61 View Code Duplication
    public function testIssueReversed() : void
62
    {
63
        $b = new DDC6499B();
64
        $a = new DDC6499A();
65
66
        $a->b = $b;
67
68
        $this->_em->persist($b);
69
        $this->_em->persist($a);
70
71
        $this->_em->flush();
72
73
        self::assertInternalType('integer', $a->id);
74
        self::assertInternalType('integer', $b->id);
75
    }
76
}
77
78
/** @Entity */
79
class DDC6499A
80
{
81
    /** @Id @Column(type="integer") @GeneratedValue */
82
    public $id;
83
84
    /** @JoinColumn(nullable=false) @OneToOne(targetEntity=DDC6499B::class) */
85
    public $b;
86
}
87
88
/** @Entity */
89
class DDC6499B
90
{
91
    /** @Id @Column(type="integer") @GeneratedValue */
92
    public $id;
93
94
    /** @ManyToOne(targetEntity="DDC6499A") */
95
    private $a;
96
}
97