Code Duplication    Length = 23-24 lines in 4 locations

tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php 2 locations

@@ 264-287 (lines=24) @@
261
        self::assertCount(0, $property->getValue($persister));
262
    }
263
264
    public function testDeleteLockFailureShouldIgnoreQueue()
265
    {
266
        $entity     = new State("Foo");
267
        $persister  = $this->createPersisterDefault();
268
        $collection = $this->createCollection($entity);
269
        $key        = new CollectionCacheKey(State::class, 'cities', ['id'=>1]);
270
        $property   = new \ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache');
271
272
        $property->setAccessible(true);
273
274
        $this->region->expects($this->once())
275
            ->method('lock')
276
            ->with($this->equalTo($key))
277
            ->will($this->returnValue(null));
278
279
        $this->collectionPersister->expects($this->once())
280
            ->method('delete')
281
            ->with($this->equalTo($collection));
282
283
        $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
284
285
        $persister->delete($collection);
286
        self::assertCount(0, $property->getValue($persister));
287
    }
288
289
    public function testUpdateLockFailureShouldIgnoreQueue()
290
    {
@@ 289-312 (lines=24) @@
286
        self::assertCount(0, $property->getValue($persister));
287
    }
288
289
    public function testUpdateLockFailureShouldIgnoreQueue()
290
    {
291
        $entity     = new State("Foo");
292
        $persister  = $this->createPersisterDefault();
293
        $collection = $this->createCollection($entity);
294
        $key        = new CollectionCacheKey(State::class, 'cities', ['id'=>1]);
295
        $property   = new \ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache');
296
297
        $property->setAccessible(true);
298
299
        $this->region->expects($this->once())
300
            ->method('lock')
301
            ->with($this->equalTo($key))
302
            ->will($this->returnValue(null));
303
304
        $this->collectionPersister->expects($this->once())
305
            ->method('update')
306
            ->with($this->equalTo($collection));
307
308
        $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
309
310
        $persister->update($collection);
311
        self::assertCount(0, $property->getValue($persister));
312
    }
313
}
314

tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php 2 locations

@@ 193-215 (lines=23) @@
190
        self::assertCount(0, $property->getValue($persister));
191
    }
192
193
    public function testDeleteLockFailureShouldIgnoreQueue()
194
    {
195
        $entity    = new Country("Foo");
196
        $persister = $this->createPersisterDefault();
197
        $key       = new EntityCacheKey(Country::class, ['id'=>1]);
198
        $property  = new \ReflectionProperty(ReadWriteCachedEntityPersister::class, 'queuedCache');
199
200
        $property->setAccessible(true);
201
202
        $this->region->expects($this->once())
203
            ->method('lock')
204
            ->with($this->equalTo($key))
205
            ->will($this->returnValue(null));
206
207
        $this->entityPersister->expects($this->once())
208
            ->method('delete')
209
            ->with($this->equalTo($entity));
210
211
        $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
212
213
        $persister->delete($entity);
214
        self::assertCount(0, $property->getValue($persister));
215
    }
216
217
    public function testUpdateLockFailureShouldIgnoreQueue()
218
    {
@@ 217-239 (lines=23) @@
214
        self::assertCount(0, $property->getValue($persister));
215
    }
216
217
    public function testUpdateLockFailureShouldIgnoreQueue()
218
    {
219
        $entity    = new Country("Foo");
220
        $persister = $this->createPersisterDefault();
221
        $key       = new EntityCacheKey(Country::class, ['id'=>1]);
222
        $property  = new \ReflectionProperty(ReadWriteCachedEntityPersister::class, 'queuedCache');
223
224
        $property->setAccessible(true);
225
226
        $this->region->expects($this->once())
227
            ->method('lock')
228
            ->with($this->equalTo($key))
229
            ->will($this->returnValue(null));
230
231
        $this->entityPersister->expects($this->once())
232
            ->method('update')
233
            ->with($this->equalTo($entity));
234
235
        $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
236
237
        $persister->update($entity);
238
        self::assertCount(0, $property->getValue($persister));
239
    }
240
}
241