4
4
5
5
namespace Doctrine \Tests \ORM \Functional ;
6
6
7
- use Doctrine \Tests \Models \Issue7877 \Issue7877ApplicationGenerated ;
8
- use Doctrine \Tests \Models \Issue7877 \Issue7877DatabaseGenerated ;
9
- use Doctrine \Tests \Models \Issue7877 \Issue7877Interface ;
7
+ use Doctrine \ORM \Annotation as ORM ;
10
8
use Doctrine \Tests \OrmFunctionalTestCase ;
11
9
12
10
class SelfReferencingTest extends OrmFunctionalTestCase
@@ -39,11 +37,9 @@ public function testDifferentEntity(string $class)
39
37
{
40
38
$ count = count ($ this ->sqlLoggerStack ->queries );
41
39
42
- /** @var Issue7877Interface $parent */
43
40
$ parent = new $ class ($ parentId = 1 );
44
41
$ this ->em ->persist ($ parent );
45
42
46
- /** @var Issue7877Interface $child */
47
43
$ child = new $ class ($ childId = 2 );
48
44
$ child ->setParent ($ parent );
49
45
$ this ->em ->persist ($ child );
@@ -92,3 +88,86 @@ public function testSameEntityDatabaseGenerated()
92
88
$ this ->assertSame ($ entityId , $ child ->getParent ()->getId ());
93
89
}
94
90
}
91
+
92
+ /**
93
+ * @ORM\Entity
94
+ */
95
+ class Issue7877ApplicationGenerated
96
+ {
97
+ public function __construct (int $ id )
98
+ {
99
+ $ this ->id = $ id ;
100
+ }
101
+
102
+ /**
103
+ * @ORM\Id
104
+ * @ORM\Column(type="integer")
105
+ * @ORM\GeneratedValue(strategy="NONE")
106
+ */
107
+ private $ id ;
108
+
109
+ public function getId (): ?int
110
+ {
111
+ return $ this ->id ;
112
+ }
113
+
114
+ public function setId (int $ id )
115
+ {
116
+ $ this ->id = $ id ;
117
+ }
118
+
119
+ /**
120
+ * @var self
121
+ * @ORM\ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Issue7877ApplicationGenerated")
122
+ */
123
+ private $ parent ;
124
+
125
+ public function getParent (): ?self
126
+ {
127
+ return $ this ->parent ;
128
+ }
129
+
130
+ public function setParent (self $ parent )
131
+ {
132
+ $ this ->parent = $ parent ;
133
+ }
134
+ }
135
+
136
+ /**
137
+ * @ORM\Entity
138
+ */
139
+ class Issue7877DatabaseGenerated
140
+ {
141
+ /**
142
+ * @ORM\Id
143
+ * @ORM\Column(type="integer")
144
+ * @ORM\GeneratedValue(strategy="AUTO")
145
+ */
146
+ private $ id ;
147
+
148
+ public function getId (): ?int
149
+ {
150
+ return $ this ->id ;
151
+ }
152
+
153
+ public function setId (int $ id )
154
+ {
155
+ $ this ->id = $ id ;
156
+ }
157
+
158
+ /**
159
+ * @var self
160
+ * @ORM\ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Issue7877DatabaseGenerated")
161
+ */
162
+ private $ parent ;
163
+
164
+ public function getParent (): ?self
165
+ {
166
+ return $ this ->parent ;
167
+ }
168
+
169
+ public function setParent (self $ parent )
170
+ {
171
+ $ this ->parent = $ parent ;
172
+ }
173
+ }
0 commit comments