|
1
|
|
|
<?php |
|
2
|
|
|
namespace Doctrine\Tests\Functional\Ticket; |
|
3
|
|
|
|
|
4
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase; |
|
5
|
|
|
|
|
6
|
|
|
final class GH6217Test extends OrmFunctionalTestCase |
|
7
|
|
|
{ |
|
8
|
|
|
public function setUp() |
|
9
|
|
|
{ |
|
10
|
|
|
$this->enableSecondLevelCache(); |
|
11
|
|
|
|
|
12
|
|
|
parent::setUp(); |
|
13
|
|
|
|
|
14
|
|
|
$this->_schemaTool->createSchema( |
|
15
|
|
|
[ |
|
16
|
|
|
$this->_em->getClassMetadata(GH6217User::class), |
|
17
|
|
|
$this->_em->getClassMetadata(GH6217Profile::class), |
|
18
|
|
|
$this->_em->getClassMetadata(GH6217Category::class), |
|
19
|
|
|
$this->_em->getClassMetadata(GH6217UserProfile::class), |
|
20
|
|
|
] |
|
21
|
|
|
); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @group 6217 |
|
26
|
|
|
*/ |
|
27
|
|
|
public function testRetrievingCacheShouldNotThrowUndefinedIndexException() |
|
28
|
|
|
{ |
|
29
|
|
|
for ($i = 1; $i < 3; $i++) { |
|
30
|
|
|
$user = new GH6217User(); |
|
31
|
|
|
$user->id = $i; |
|
32
|
|
|
$user->username = "user$i"; |
|
33
|
|
|
$profile = new GH6217Profile(); |
|
34
|
|
|
$profile->id = $i; |
|
35
|
|
|
$category = new GH6217Category(); |
|
36
|
|
|
$category->id = $i; |
|
37
|
|
|
$category->title = "category$i"; |
|
38
|
|
|
$this->_em->persist($user); |
|
39
|
|
|
$this->_em->persist($profile); |
|
40
|
|
|
$this->_em->persist($category); |
|
41
|
|
|
$this->_em->flush(); |
|
42
|
|
|
} |
|
43
|
|
|
for ($i = 1; $i < 3; $i++) { |
|
44
|
|
|
$category = $this->_em->getRepository(GH6217Category::class)->find($i); |
|
45
|
|
|
$user = $this->_em->getRepository(GH6217User::class)->find($i); |
|
46
|
|
|
for ($x = 1; $x < 3; $x++) { |
|
47
|
|
|
$profile = $this->_em->getRepository(GH6217Profile::class)->find($x); |
|
48
|
|
|
$userProfile = new GH6217UserProfile(); |
|
49
|
|
|
$userProfile->profile = $profile; |
|
50
|
|
|
$userProfile->category = $category; |
|
51
|
|
|
$userProfile->user = $user; |
|
52
|
|
|
$this->_em->persist($userProfile); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
$this->_em->flush(); |
|
56
|
|
|
$this->_em->clear(); |
|
57
|
|
|
|
|
58
|
|
|
$id = 2; |
|
59
|
|
|
/** @var GH6217UserProfile[] $userProfiles */ |
|
60
|
|
|
$userProfiles = $this->_em->getRepository(GH6217UserProfile::class)->findBy( |
|
61
|
|
|
[ |
|
62
|
|
|
'user' => $id, |
|
63
|
|
|
'category' => $id, |
|
64
|
|
|
] |
|
65
|
|
|
); |
|
66
|
|
|
$queryCount = $this->getCurrentQueryCount(); |
|
67
|
|
|
$this->_em->clear(); |
|
68
|
|
|
|
|
69
|
|
|
$this->_em->getRepository(GH6217UserProfile::class)->findBy( |
|
70
|
|
|
[ |
|
71
|
|
|
'user' => $id, |
|
72
|
|
|
'category' => $id, |
|
73
|
|
|
] |
|
74
|
|
|
); |
|
75
|
|
|
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); |
|
76
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @Entity() |
|
83
|
|
|
* @Cache(usage="NONSTRICT_READ_WRITE", region="user_profile_region") |
|
84
|
|
|
*/ |
|
85
|
|
|
class GH6217UserProfile |
|
86
|
|
|
{ |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @var GH6217User |
|
90
|
|
|
* |
|
91
|
|
|
* @Id; |
|
92
|
|
|
* @ManyToOne(targetEntity="GH6217User") |
|
93
|
|
|
* @JoinColumn(nullable=false) |
|
94
|
|
|
* @Cache("NONSTRICT_READ_WRITE") |
|
95
|
|
|
*/ |
|
96
|
|
|
public $user; |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @var GH6217Profile |
|
100
|
|
|
* |
|
101
|
|
|
* @Id; |
|
102
|
|
|
* @ManyToOne(targetEntity="GH6217Profile", inversedBy="userProfiles", fetch="EAGER") |
|
103
|
|
|
* @Cache("NONSTRICT_READ_WRITE") |
|
104
|
|
|
*/ |
|
105
|
|
|
public $profile; |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @var GH6217Category |
|
109
|
|
|
* |
|
110
|
|
|
* @Id; |
|
111
|
|
|
* @ManyToOne(targetEntity="GH6217Category", inversedBy="userProfiles") |
|
112
|
|
|
* @Cache("NONSTRICT_READ_WRITE") |
|
113
|
|
|
*/ |
|
114
|
|
|
public $category; |
|
115
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @Entity() |
|
122
|
|
|
* @Cache(usage="NONSTRICT_READ_WRITE", region="category_region") |
|
123
|
|
|
*/ |
|
124
|
|
|
class GH6217Category |
|
125
|
|
|
{ |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* @var int |
|
129
|
|
|
* @Id; |
|
130
|
|
|
* @Column(type="integer") |
|
131
|
|
|
* |
|
132
|
|
|
*/ |
|
133
|
|
|
public $id; |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @var GH6217UserProfile[] |
|
137
|
|
|
* @OneToMany(targetEntity="GH6217UserProfile", mappedBy="category") |
|
138
|
|
|
* @Cache("NONSTRICT_READ_WRITE") |
|
139
|
|
|
*/ |
|
140
|
|
|
public $userProfiles; |
|
141
|
|
|
|
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* @Entity() |
|
146
|
|
|
* @Cache(usage="NONSTRICT_READ_WRITE", region="user_region") |
|
147
|
|
|
*/ |
|
148
|
|
|
class GH6217User |
|
149
|
|
|
{ |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* @Id; |
|
153
|
|
|
* @Column(type="integer") |
|
154
|
|
|
* |
|
155
|
|
|
*/ |
|
156
|
|
|
public $id; |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* @var string |
|
160
|
|
|
* @Column(type="string", length=60, unique=true) |
|
161
|
|
|
*/ |
|
162
|
|
|
public $username; |
|
163
|
|
|
|
|
164
|
|
|
|
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* @Entity() |
|
170
|
|
|
* @Cache(usage="NONSTRICT_READ_WRITE", region="profile_region") |
|
171
|
|
|
*/ |
|
172
|
|
|
class GH6217Profile |
|
173
|
|
|
{ |
|
174
|
|
|
|
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @Id; |
|
178
|
|
|
* @Column(type="integer") |
|
179
|
|
|
* |
|
180
|
|
|
*/ |
|
181
|
|
|
public $id; |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* @var GH6217UserProfile[] |
|
185
|
|
|
* @OneToMany(targetEntity="GH6217UserProfile", mappedBy="profile") |
|
186
|
|
|
* @Cache("NONSTRICT_READ_WRITE") |
|
187
|
|
|
*/ |
|
188
|
|
|
public $userProfiles; |
|
189
|
|
|
|
|
190
|
|
|
|
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
|
|
194
|
|
|
|
|
195
|
|
|
|