@@ 140-169 (lines=30) @@ | ||
137 | $persister->afterTransactionRolledBack(); |
|
138 | } |
|
139 | ||
140 | public function testTransactionRollBackDeleteShouldClearQueue() |
|
141 | { |
|
142 | $entity = new State("Foo"); |
|
143 | $lock = Lock::createLockRead(); |
|
144 | $persister = $this->createPersisterDefault(); |
|
145 | $collection = $this->createCollection($entity); |
|
146 | $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]); |
|
147 | $property = new \ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache'); |
|
148 | ||
149 | $property->setAccessible(true); |
|
150 | ||
151 | $this->region->expects($this->once()) |
|
152 | ->method('lock') |
|
153 | ->with($this->equalTo($key)) |
|
154 | ->will($this->returnValue($lock)); |
|
155 | ||
156 | $this->region->expects($this->once()) |
|
157 | ->method('evict') |
|
158 | ->with($this->equalTo($key)); |
|
159 | ||
160 | $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']); |
|
161 | ||
162 | $persister->delete($collection); |
|
163 | ||
164 | self::assertCount(1, $property->getValue($persister)); |
|
165 | ||
166 | $persister->afterTransactionRolledBack(); |
|
167 | ||
168 | self::assertCount(0, $property->getValue($persister)); |
|
169 | } |
|
170 | ||
171 | public function testTransactionRollBackUpdateShouldClearQueue() |
|
172 | { |
|
@@ 171-200 (lines=30) @@ | ||
168 | self::assertCount(0, $property->getValue($persister)); |
|
169 | } |
|
170 | ||
171 | public function testTransactionRollBackUpdateShouldClearQueue() |
|
172 | { |
|
173 | $entity = new State("Foo"); |
|
174 | $lock = Lock::createLockRead(); |
|
175 | $persister = $this->createPersisterDefault(); |
|
176 | $collection = $this->createCollection($entity); |
|
177 | $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]); |
|
178 | $property = new \ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache'); |
|
179 | ||
180 | $property->setAccessible(true); |
|
181 | ||
182 | $this->region->expects($this->once()) |
|
183 | ->method('lock') |
|
184 | ->with($this->equalTo($key)) |
|
185 | ->will($this->returnValue($lock)); |
|
186 | ||
187 | $this->region->expects($this->once()) |
|
188 | ->method('evict') |
|
189 | ->with($this->equalTo($key)); |
|
190 | ||
191 | $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']); |
|
192 | ||
193 | $persister->update($collection); |
|
194 | ||
195 | self::assertCount(1, $property->getValue($persister)); |
|
196 | ||
197 | $persister->afterTransactionRolledBack(); |
|
198 | ||
199 | self::assertCount(0, $property->getValue($persister)); |
|
200 | } |
|
201 | ||
202 | public function testTransactionRollCommitDeleteShouldClearQueue() |
|
203 | { |
|
@@ 202-231 (lines=30) @@ | ||
199 | self::assertCount(0, $property->getValue($persister)); |
|
200 | } |
|
201 | ||
202 | public function testTransactionRollCommitDeleteShouldClearQueue() |
|
203 | { |
|
204 | $entity = new State("Foo"); |
|
205 | $lock = Lock::createLockRead(); |
|
206 | $persister = $this->createPersisterDefault(); |
|
207 | $collection = $this->createCollection($entity); |
|
208 | $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]); |
|
209 | $property = new \ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache'); |
|
210 | ||
211 | $property->setAccessible(true); |
|
212 | ||
213 | $this->region->expects($this->once()) |
|
214 | ->method('lock') |
|
215 | ->with($this->equalTo($key)) |
|
216 | ->will($this->returnValue($lock)); |
|
217 | ||
218 | $this->region->expects($this->once()) |
|
219 | ->method('evict') |
|
220 | ->with($this->equalTo($key)); |
|
221 | ||
222 | $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']); |
|
223 | ||
224 | $persister->delete($collection); |
|
225 | ||
226 | self::assertCount(1, $property->getValue($persister)); |
|
227 | ||
228 | $persister->afterTransactionComplete(); |
|
229 | ||
230 | self::assertCount(0, $property->getValue($persister)); |
|
231 | } |
|
232 | ||
233 | public function testTransactionRollCommitUpdateShouldClearQueue() |
|
234 | { |
|
@@ 233-262 (lines=30) @@ | ||
230 | self::assertCount(0, $property->getValue($persister)); |
|
231 | } |
|
232 | ||
233 | public function testTransactionRollCommitUpdateShouldClearQueue() |
|
234 | { |
|
235 | $entity = new State("Foo"); |
|
236 | $lock = Lock::createLockRead(); |
|
237 | $persister = $this->createPersisterDefault(); |
|
238 | $collection = $this->createCollection($entity); |
|
239 | $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]); |
|
240 | $property = new \ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache'); |
|
241 | ||
242 | $property->setAccessible(true); |
|
243 | ||
244 | $this->region->expects($this->once()) |
|
245 | ->method('lock') |
|
246 | ->with($this->equalTo($key)) |
|
247 | ->will($this->returnValue($lock)); |
|
248 | ||
249 | $this->region->expects($this->once()) |
|
250 | ->method('evict') |
|
251 | ->with($this->equalTo($key)); |
|
252 | ||
253 | $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']); |
|
254 | ||
255 | $persister->update($collection); |
|
256 | ||
257 | self::assertCount(1, $property->getValue($persister)); |
|
258 | ||
259 | $persister->afterTransactionComplete(); |
|
260 | ||
261 | self::assertCount(0, $property->getValue($persister)); |
|
262 | } |
|
263 | ||
264 | public function testDeleteLockFailureShouldIgnoreQueue() |
|
265 | { |
@@ 131-160 (lines=30) @@ | ||
128 | $persister->afterTransactionRolledBack(); |
|
129 | } |
|
130 | ||
131 | public function testTransactionRollBackShouldClearQueue() |
|
132 | { |
|
133 | $entity = new Country("Foo"); |
|
134 | $lock = Lock::createLockRead(); |
|
135 | $persister = $this->createPersisterDefault(); |
|
136 | $key = new EntityCacheKey(Country::class, ['id'=>1]); |
|
137 | $property = new \ReflectionProperty(ReadWriteCachedEntityPersister::class, 'queuedCache'); |
|
138 | ||
139 | $property->setAccessible(true); |
|
140 | ||
141 | $this->region->expects($this->exactly(2)) |
|
142 | ->method('lock') |
|
143 | ->with($this->equalTo($key)) |
|
144 | ->will($this->returnValue($lock)); |
|
145 | ||
146 | $this->region->expects($this->exactly(2)) |
|
147 | ->method('evict') |
|
148 | ->with($this->equalTo($key)); |
|
149 | ||
150 | $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']); |
|
151 | ||
152 | $persister->update($entity); |
|
153 | $persister->delete($entity); |
|
154 | ||
155 | self::assertCount(2, $property->getValue($persister)); |
|
156 | ||
157 | $persister->afterTransactionRolledBack(); |
|
158 | ||
159 | self::assertCount(0, $property->getValue($persister)); |
|
160 | } |
|
161 | ||
162 | public function testTransactionCommitShouldClearQueue() |
|
163 | { |
|
@@ 162-191 (lines=30) @@ | ||
159 | self::assertCount(0, $property->getValue($persister)); |
|
160 | } |
|
161 | ||
162 | public function testTransactionCommitShouldClearQueue() |
|
163 | { |
|
164 | $entity = new Country("Foo"); |
|
165 | $lock = Lock::createLockRead(); |
|
166 | $persister = $this->createPersisterDefault(); |
|
167 | $key = new EntityCacheKey(Country::class, ['id'=>1]); |
|
168 | $property = new \ReflectionProperty(ReadWriteCachedEntityPersister::class, 'queuedCache'); |
|
169 | ||
170 | $property->setAccessible(true); |
|
171 | ||
172 | $this->region->expects($this->exactly(2)) |
|
173 | ->method('lock') |
|
174 | ->with($this->equalTo($key)) |
|
175 | ->will($this->returnValue($lock)); |
|
176 | ||
177 | $this->region->expects($this->exactly(2)) |
|
178 | ->method('evict') |
|
179 | ->with($this->equalTo($key)); |
|
180 | ||
181 | $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']); |
|
182 | ||
183 | $persister->update($entity); |
|
184 | $persister->delete($entity); |
|
185 | ||
186 | self::assertCount(2, $property->getValue($persister)); |
|
187 | ||
188 | $persister->afterTransactionComplete(); |
|
189 | ||
190 | self::assertCount(0, $property->getValue($persister)); |
|
191 | } |
|
192 | ||
193 | public function testDeleteLockFailureShouldIgnoreQueue() |
|
194 | { |