|
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
|
|
|
$user = new GH6217User(1, 'user 1'); |
|
30
|
|
|
$profile = new GH6217Profile(1); |
|
31
|
|
|
$category = new GH6217Category(1, 'category 1'); |
|
32
|
|
|
|
|
33
|
|
|
$this->_em->persist($category); |
|
34
|
|
|
$this->_em->persist($user); |
|
35
|
|
|
$this->_em->persist($profile); |
|
36
|
|
|
$this->_em->persist(new GH6217UserProfile($user, $profile, $category)); |
|
37
|
|
|
$this->_em->flush(); |
|
38
|
|
|
$this->_em->clear(); |
|
39
|
|
|
|
|
40
|
|
|
$repository = $this->_em->getRepository(GH6217UserProfile::class); |
|
41
|
|
|
$filters = ['user' => 1, 'category' => 1]; |
|
42
|
|
|
|
|
43
|
|
|
$this->assertCount(1, $repository->findBy($filters)); |
|
44
|
|
|
$queryCount = $this->getCurrentQueryCount(); |
|
45
|
|
|
|
|
46
|
|
|
$this->_em->clear(); |
|
47
|
|
|
|
|
48
|
|
|
$this->assertCount(1, $repository->findBy($filters)); |
|
49
|
|
|
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); |
|
50
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @Entity |
|
56
|
|
|
* @Cache(usage="NONSTRICT_READ_WRITE") |
|
57
|
|
|
*/ |
|
58
|
|
|
class GH6217User |
|
59
|
|
|
{ |
|
60
|
|
|
/** |
|
61
|
|
|
* @Id |
|
62
|
|
|
* @Column(type="integer") |
|
63
|
|
|
* |
|
64
|
|
|
* @var int |
|
65
|
|
|
*/ |
|
66
|
|
|
public $id; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @Column(type="string", length=60, unique=true) |
|
70
|
|
|
* |
|
71
|
|
|
* @var string |
|
72
|
|
|
*/ |
|
73
|
|
|
public $username; |
|
74
|
|
|
|
|
75
|
|
|
public function __construct(int $id, string $username) |
|
76
|
|
|
{ |
|
77
|
|
|
$this->id = $id; |
|
78
|
|
|
$this->username = $username; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @Entity |
|
84
|
|
|
* @Cache(usage="NONSTRICT_READ_WRITE") |
|
85
|
|
|
*/ |
|
86
|
|
|
class GH6217Profile |
|
87
|
|
|
{ |
|
88
|
|
|
/** |
|
89
|
|
|
* @Id |
|
90
|
|
|
* @Column(type="integer") |
|
91
|
|
|
* |
|
92
|
|
|
* @var int |
|
93
|
|
|
*/ |
|
94
|
|
|
public $id; |
|
95
|
|
|
|
|
96
|
|
|
public function __construct(int $id) |
|
97
|
|
|
{ |
|
98
|
|
|
$this->id = $id; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @Entity |
|
104
|
|
|
* @Cache(usage="NONSTRICT_READ_WRITE") |
|
105
|
|
|
*/ |
|
106
|
|
|
class GH6217Category |
|
107
|
|
|
{ |
|
108
|
|
|
/** |
|
109
|
|
|
* @Id |
|
110
|
|
|
* @Column(type="integer") |
|
111
|
|
|
* |
|
112
|
|
|
* @var int |
|
113
|
|
|
*/ |
|
114
|
|
|
public $id; |
|
115
|
|
|
|
|
116
|
|
|
public function __construct(int $id) |
|
117
|
|
|
{ |
|
118
|
|
|
$this->id = $id; |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @Entity |
|
124
|
|
|
* @Cache(usage="NONSTRICT_READ_WRITE") |
|
125
|
|
|
*/ |
|
126
|
|
|
class GH6217UserProfile |
|
127
|
|
|
{ |
|
128
|
|
|
/** |
|
129
|
|
|
* @Id |
|
130
|
|
|
* @Cache("NONSTRICT_READ_WRITE") |
|
131
|
|
|
* @ManyToOne(targetEntity="GH6217User") |
|
132
|
|
|
* @JoinColumn(nullable=false) |
|
133
|
|
|
* |
|
134
|
|
|
* @var GH6217User |
|
135
|
|
|
*/ |
|
136
|
|
|
public $user; |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @Id |
|
140
|
|
|
* @Cache("NONSTRICT_READ_WRITE") |
|
141
|
|
|
* @ManyToOne(targetEntity="GH6217Profile", fetch="EAGER") |
|
142
|
|
|
* |
|
143
|
|
|
* @var GH6217Profile |
|
144
|
|
|
*/ |
|
145
|
|
|
public $profile; |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* @Id |
|
149
|
|
|
* @Cache("NONSTRICT_READ_WRITE") |
|
150
|
|
|
* @ManyToOne(targetEntity="GH6217Category", fetch="EAGER") |
|
151
|
|
|
* |
|
152
|
|
|
* @var GH6217Category |
|
153
|
|
|
*/ |
|
154
|
|
|
public $category; |
|
155
|
|
|
|
|
156
|
|
|
public function __construct(GH6217User $user, GH6217Profile $profile, GH6217Category $category) |
|
157
|
|
|
{ |
|
158
|
|
|
$this->user = $user; |
|
159
|
|
|
$this->profile = $profile; |
|
160
|
|
|
$this->category = $category; |
|
161
|
|
|
} |
|
162
|
|
|
} |
|
163
|
|
|
|