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 7180 |
10
|
|
|
*/ |
11
|
|
|
class DDC7180Test extends OrmFunctionalTestCase |
12
|
|
|
{ |
13
|
|
|
private static $createdSchema = false; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* {@inheritDoc} |
17
|
|
|
*/ |
18
|
|
|
protected function setUp() : void |
19
|
|
|
{ |
20
|
|
|
parent::setUp(); |
21
|
|
|
|
22
|
|
|
if (self::$createdSchema) { |
23
|
|
|
return; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
$this->_schemaTool->createSchema([ |
27
|
|
|
$this->_em->getClassMetadata(DDC7180A::class), |
28
|
|
|
$this->_em->getClassMetadata(DDC7180B::class), |
29
|
|
|
$this->_em->getClassMetadata(DDC7180C::class), |
30
|
|
|
$this->_em->getClassMetadata(DDC7180D::class), |
31
|
|
|
$this->_em->getClassMetadata(DDC7180E::class), |
32
|
|
|
$this->_em->getClassMetadata(DDC7180F::class), |
33
|
|
|
$this->_em->getClassMetadata(DDC7180G::class), |
34
|
|
|
]); |
35
|
|
|
|
36
|
|
|
self::$createdSchema = true; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritDoc} |
41
|
|
|
*/ |
42
|
|
|
protected function tearDown() : void |
43
|
|
|
{ |
44
|
|
|
parent::tearDown(); |
45
|
|
|
|
46
|
|
|
$this->_schemaTool->dropSchema([ |
47
|
|
|
$this->_em->getClassMetadata(DDC7180A::class), |
48
|
|
|
$this->_em->getClassMetadata(DDC7180B::class), |
49
|
|
|
$this->_em->getClassMetadata(DDC7180C::class), |
50
|
|
|
]); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testIssue() : void |
54
|
|
|
{ |
55
|
|
|
$a = new DDC7180A(); |
56
|
|
|
$b = new DDC7180B(); |
57
|
|
|
$c = new DDC7180C(); |
58
|
|
|
|
59
|
|
|
$a->b = $b; |
60
|
|
|
$b->a = $a; |
61
|
|
|
$c->a = $a; |
62
|
|
|
|
63
|
|
|
$this->_em->persist($a); |
64
|
|
|
$this->_em->persist($b); |
65
|
|
|
$this->_em->persist($c); |
66
|
|
|
|
67
|
|
|
$this->_em->flush(); |
68
|
|
|
|
69
|
|
|
self::assertInternalType('integer', $a->id); |
70
|
|
|
self::assertInternalType('integer', $b->id); |
71
|
|
|
self::assertInternalType('integer', $c->id); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function testIssue3NodeCycle() : void |
75
|
|
|
{ |
76
|
|
|
$d = new DDC7180D(); |
77
|
|
|
$e = new DDC7180E(); |
78
|
|
|
$f = new DDC7180F(); |
79
|
|
|
$g = new DDC7180G(); |
80
|
|
|
|
81
|
|
|
$d->e = $e; |
82
|
|
|
$e->f = $f; |
83
|
|
|
$f->d = $d; |
84
|
|
|
$g->d = $d; |
85
|
|
|
|
86
|
|
|
$this->_em->persist($d); |
87
|
|
|
$this->_em->persist($e); |
88
|
|
|
$this->_em->persist($f); |
89
|
|
|
$this->_em->persist($g); |
90
|
|
|
|
91
|
|
|
$this->_em->flush(); |
92
|
|
|
|
93
|
|
|
self::assertInternalType('integer', $d->id); |
94
|
|
|
self::assertInternalType('integer', $e->id); |
95
|
|
|
self::assertInternalType('integer', $f->id); |
96
|
|
|
self::assertInternalType('integer', $g->id); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @Entity |
102
|
|
|
*/ |
103
|
|
|
class DDC7180A |
104
|
|
|
{ |
105
|
|
|
/** |
106
|
|
|
* @GeneratedValue() |
107
|
|
|
* @Id @Column(type="integer") |
108
|
|
|
*/ |
109
|
|
|
public $id; |
110
|
|
|
/** |
111
|
|
|
* @OneToOne(targetEntity=DDC7180B::class, inversedBy="a") |
112
|
|
|
* @JoinColumn(nullable=false) |
113
|
|
|
*/ |
114
|
|
|
public $b; |
115
|
|
|
} |
116
|
|
|
/** |
117
|
|
|
* @Entity |
118
|
|
|
*/ |
119
|
|
|
class DDC7180B |
120
|
|
|
{ |
121
|
|
|
/** |
122
|
|
|
* @GeneratedValue() |
123
|
|
|
* @Id @Column(type="integer") |
124
|
|
|
*/ |
125
|
|
|
public $id; |
126
|
|
|
/** |
127
|
|
|
* @OneToOne(targetEntity=DDC7180A::class, mappedBy="b") |
128
|
|
|
* @JoinColumn(nullable=true) |
129
|
|
|
*/ |
130
|
|
|
public $a; |
131
|
|
|
} |
132
|
|
|
/** |
133
|
|
|
* @Entity |
134
|
|
|
*/ |
135
|
|
|
class DDC7180C |
136
|
|
|
{ |
137
|
|
|
/** |
138
|
|
|
* @GeneratedValue() |
139
|
|
|
* @Id @Column(type="integer") |
140
|
|
|
*/ |
141
|
|
|
public $id; |
142
|
|
|
/** |
143
|
|
|
* @ManyToOne(targetEntity=DDC7180A::class) |
144
|
|
|
* @JoinColumn(nullable=false) |
145
|
|
|
*/ |
146
|
|
|
public $a; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @Entity |
151
|
|
|
*/ |
152
|
|
|
class DDC7180D |
153
|
|
|
{ |
154
|
|
|
/** |
155
|
|
|
* @GeneratedValue() |
156
|
|
|
* @Id @Column(type="integer") |
157
|
|
|
*/ |
158
|
|
|
public $id; |
159
|
|
|
/** |
160
|
|
|
* @OneToOne(targetEntity=DDC7180E::class) |
161
|
|
|
* @JoinColumn(nullable=false) |
162
|
|
|
*/ |
163
|
|
|
public $e; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @Entity |
168
|
|
|
*/ |
169
|
|
|
class DDC7180E |
170
|
|
|
{ |
171
|
|
|
/** |
172
|
|
|
* @GeneratedValue() |
173
|
|
|
* @Id @Column(type="integer") |
174
|
|
|
*/ |
175
|
|
|
public $id; |
176
|
|
|
/** |
177
|
|
|
* @OneToOne(targetEntity=DDC7180F::class) |
178
|
|
|
* @JoinColumn(nullable=false) |
179
|
|
|
*/ |
180
|
|
|
public $f; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @Entity |
185
|
|
|
*/ |
186
|
|
|
class DDC7180F |
187
|
|
|
{ |
188
|
|
|
/** |
189
|
|
|
* @GeneratedValue() |
190
|
|
|
* @Id @Column(type="integer") |
191
|
|
|
*/ |
192
|
|
|
public $id; |
193
|
|
|
/** |
194
|
|
|
* @ManyToOne(targetEntity=DDC7180D::class) |
195
|
|
|
* @JoinColumn(nullable=true) |
196
|
|
|
*/ |
197
|
|
|
public $d; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @Entity |
202
|
|
|
*/ |
203
|
|
|
class DDC7180G |
204
|
|
|
{ |
205
|
|
|
/** |
206
|
|
|
* @GeneratedValue() |
207
|
|
|
* @Id @Column(type="integer") |
208
|
|
|
*/ |
209
|
|
|
public $id; |
210
|
|
|
/** |
211
|
|
|
* @ManyToOne(targetEntity=DDC7180D::class) |
212
|
|
|
* @JoinColumn(nullable=false) |
213
|
|
|
*/ |
214
|
|
|
public $d; |
215
|
|
|
} |
216
|
|
|
|