Code Duplication    Length = 19-19 lines in 3 locations

eZ/Publish/Core/Persistence/Cache/Tests/ObjectStateHandlerTest.php 3 locations

@@ 243-261 (lines=19) @@
240
            ->with(0, -1)
241
            ->will($this->returnValue($testGroups));
242
243
        foreach ($testGroups as $group) {
244
            $this->cacheMock
245
                ->expects($this->at($group->id))
246
                ->method('getItem')
247
                ->with('objectstategroup', $group->id)
248
                ->will(
249
                    $this->returnCallback(
250
                        function ($cachekey, $i) use ($group) {
251
                            $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
252
                            $cacheItemMock
253
                                ->expects($this->once())
254
                                ->method('set')
255
                                ->with($group);
256
257
                            return $cacheItemMock;
258
                        }
259
                    )
260
                );
261
        }
262
263
        $cacheItemMock
264
            ->expects($this->once())
@@ 306-324 (lines=19) @@
303
        $expectedGroups = array_slice($testGroups, $offset, $limit > -1 ?: null);
304
305
        // loadGroup()
306
        foreach ($expectedGroups as $i => $group) {
307
            $this->cacheMock
308
                ->expects($this->at($i + 1))
309
                ->method('getItem')
310
                ->with('objectstategroup', $group->id)
311
                ->will(
312
                    $this->returnCallback(
313
                        function ($cachekey, $i) use ($group) {
314
                            $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
315
                            $cacheItemMock
316
                                ->expects($this->once())
317
                                ->method('get')
318
                                ->will($this->returnValue($group));
319
320
                            return $cacheItemMock;
321
                        }
322
                    )
323
                );
324
        }
325
326
        $handler = $this->persistenceCacheHandler->objectStateHandler();
327
        $groups = $handler->loadAllGroups($offset, $limit);
@@ 472-490 (lines=19) @@
469
            ->will($this->returnValue(false));
470
471
        // load()
472
        foreach ($testStates as $i => $state) {
473
            $this->cacheMock
474
                ->expects($this->at($i + 1))
475
                ->method('getItem')
476
                ->with('objectstate', $state->id)
477
                ->will(
478
                    $this->returnCallback(
479
                        function ($cachekey, $i) use ($state) {
480
                            $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
481
                            $cacheItemMock
482
                                ->expects($this->once())
483
                                ->method('get')
484
                                ->will($this->returnValue($state));
485
486
                            return $cacheItemMock;
487
                        }
488
                    )
489
                );
490
        }
491
492
        $handler = $this->persistenceCacheHandler->objectStateHandler();
493
        $states = $handler->loadObjectStates(1);