Completed
Pull Request — master (#7405)
by Michael
68:49 queued 63:08
created

GH7259Test::testPersistFileBeforeVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 0
dl 0
loc 22
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\ORM\Functional\Ticket;
6
7
use Doctrine\ORM\Annotation as ORM;
8
use Doctrine\Tests\OrmFunctionalTestCase;
9
10
final class GH7259Test extends OrmFunctionalTestCase
11
{
12
    protected function setUp() : void
13
    {
14
        parent::setUp();
15
16
        $this->setUpEntitySchema([GH7259Space::class, GH7259File::class, GH7259FileVersion::class, GH7259Feed::class]);
17
    }
18
19
    /**
20
     * @group 7259
21
     */
22
    public function testPersistFileBeforeVersion() : void
23
    {
24
        $space = new GH7259Space();
25
26
        $this->em->persist($space);
27
        $this->em->flush();
28
29
        $feed        = new GH7259Feed();
30
        $feed->space = $space;
31
32
        $file              = new GH7259File();
33
        $file->space       = $space;
34
        $fileVersion       = new GH7259FileVersion();
35
        $fileVersion->file = $file;
36
37
        $this->em->persist($file);
38
        $this->em->persist($fileVersion);
39
        $this->em->persist($feed);
40
41
        $this->em->flush();
42
43
        self::assertNotNull($fileVersion->id);
44
    }
45
46
    /**
47
     * @group 7259
48
     */
49
    public function testPersistFileAfterVersion() : void
50
    {
51
        $space = new GH7259Space();
52
53
        $this->em->persist($space);
54
        $this->em->flush();
55
        $this->em->clear();
56
57
        $space = $this->em->find(GH7259Space::class, $space->id);
58
59
        $feed        = new GH7259Feed();
60
        $feed->space = $space;
61
62
        $file              = new GH7259File();
63
        $file->space       = $space;
64
        $fileVersion       = new GH7259FileVersion();
65
        $fileVersion->file = $file;
66
67
        $this->em->persist($fileVersion);
68
        $this->em->persist($file);
69
        $this->em->persist($feed);
70
71
        $this->em->flush();
72
73
        self::assertNotNull($fileVersion->id);
74
    }
75
}
76
77
/**
78
 * @ORM\Entity()
79
 */
80
class GH7259File
81
{
82
    /**
83
     * @ORM\Id
84
     * @ORM\GeneratedValue
85
     * @ORM\Column(type="integer")
86
     *
87
     * @var int
88
     */
89
    public $id;
90
91
    /**
92
     * @ORM\ManyToOne(targetEntity=GH7259Space::class)
93
     * @ORM\JoinColumn(nullable=false)
94
     *
95
     * @var GH7259Space|null
96
     */
97
    public $space;
98
}
99
100
/**
101
 * @ORM\Entity()
102
 */
103
class GH7259FileVersion
104
{
105
    /**
106
     * @ORM\Id
107
     * @ORM\GeneratedValue
108
     * @ORM\Column(type="integer")
109
     *
110
     * @var int
111
     */
112
    public $id;
113
114
    /**
115
     * @ORM\ManyToOne(targetEntity=GH7259File::class)
116
     * @ORM\JoinColumn(nullable=false)
117
     *
118
     * @var GH7259File|null
119
     */
120
    public $file;
121
}
122
123
/**
124
 * @ORM\Entity()
125
 */
126
class GH7259Space
127
{
128
    /**
129
     * @ORM\Id
130
     * @ORM\GeneratedValue
131
     * @ORM\Column(type="integer")
132
     *
133
     * @var int
134
     */
135
    public $id;
136
137
    /**
138
     * @ORM\ManyToOne(targetEntity=GH7259File::class)
139
     * @ORM\JoinColumn(nullable=true)
140
     *
141
     * @var GH7259File|null
142
     */
143
    public $ruleFile;
144
}
145
146
/**
147
 * @ORM\Entity()
148
 */
149
class GH7259Feed
150
{
151
    /**
152
     * @ORM\Id
153
     * @ORM\GeneratedValue
154
     * @ORM\Column(type="integer")
155
     *
156
     * @var int
157
     */
158
    public $id;
159
160
    /**
161
     * @ORM\ManyToOne(targetEntity=GH7259Space::class)
162
     * @ORM\JoinColumn(nullable=false)
163
     *
164
     * @var GH7259Space|null
165
     */
166
    public $space;
167
}
168