Code Duplication    Length = 53-54 lines in 4 locations

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

@@ 172-225 (lines=54) @@
169
    /**
170
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent
171
     */
172
    public function testLoadLocationsByContentHasCache()
173
    {
174
        $this->loggerMock->expects($this->never())->method($this->anything());
175
176
        $this->persistenceHandlerMock
177
            ->expects($this->never())
178
            ->method($this->anything());
179
180
        $cacheItemMock = $this->getCacheItemMock();
181
        $this->cacheMock
182
            ->expects($this->at(0))
183
            ->method('getItem')
184
            ->with('content', 'locations', 44)
185
            ->will($this->returnValue($cacheItemMock));
186
187
        $cacheItemMock
188
            ->expects($this->once())
189
            ->method('get')
190
            ->will($this->returnValue([33]));
191
192
        $cacheItemMock
193
            ->expects($this->once())
194
            ->method('isMiss')
195
            ->will($this->returnValue(false));
196
197
        $cacheItemMock
198
            ->expects($this->never())
199
            ->method('set');
200
201
        // inline call to load()
202
        $cacheItemMock2 = $this->getCacheItemMock();
203
        $this->cacheMock
204
            ->expects($this->at(1))
205
            ->method('getItem')
206
            ->with('location', 33)
207
            ->will($this->returnValue($cacheItemMock2));
208
209
        $cacheItemMock2
210
            ->expects($this->once())
211
            ->method('get')
212
            ->will($this->returnValue(new Location(['id' => 33])));
213
214
        $cacheItemMock2
215
            ->expects($this->once())
216
            ->method('isMiss')
217
            ->will($this->returnValue(false));
218
219
        $cacheItemMock2
220
            ->expects($this->never())
221
            ->method('set');
222
223
        $handler = $this->persistenceCacheHandler->locationHandler();
224
        $handler->loadLocationsByContent(44);
225
    }
226
227
    /**
228
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent
@@ 280-333 (lines=54) @@
277
    /**
278
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent
279
     */
280
    public function testLoadParentLocationsForDraftContentHasCache()
281
    {
282
        $this->loggerMock->expects($this->never())->method($this->anything());
283
284
        $this->persistenceHandlerMock
285
            ->expects($this->never())
286
            ->method($this->anything());
287
288
        $cacheItemMock = $this->getCacheItemMock();
289
        $this->cacheMock
290
            ->expects($this->at(0))
291
            ->method('getItem')
292
            ->with('content', 'locations', '44', 'parentLocationsForDraftContent')
293
            ->will($this->returnValue($cacheItemMock));
294
295
        $cacheItemMock
296
            ->expects($this->once())
297
            ->method('get')
298
            ->will($this->returnValue([33]));
299
300
        $cacheItemMock
301
            ->expects($this->once())
302
            ->method('isMiss')
303
            ->will($this->returnValue(false));
304
305
        $cacheItemMock
306
            ->expects($this->never())
307
            ->method('set');
308
309
        // inline call to load()
310
        $cacheItemMock2 = $this->getCacheItemMock();
311
        $this->cacheMock
312
            ->expects($this->at(1))
313
            ->method('getItem')
314
            ->with('location', 33)
315
            ->will($this->returnValue($cacheItemMock2));
316
317
        $cacheItemMock2
318
            ->expects($this->once())
319
            ->method('get')
320
            ->will($this->returnValue(new Location(['id' => 33])));
321
322
        $cacheItemMock2
323
            ->expects($this->once())
324
            ->method('isMiss')
325
            ->will($this->returnValue(false));
326
327
        $cacheItemMock2
328
            ->expects($this->never())
329
            ->method('set');
330
331
        $handler = $this->persistenceCacheHandler->locationHandler();
332
        $handler->loadParentLocationsForDraftContent(44);
333
    }
334
335
    /**
336
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent
@@ 388-441 (lines=54) @@
385
    /**
386
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent
387
     */
388
    public function testLoadLocationsByContentWithRootHasCache()
389
    {
390
        $this->loggerMock->expects($this->never())->method($this->anything());
391
392
        $this->persistenceHandlerMock
393
            ->expects($this->never())
394
            ->method($this->anything());
395
396
        $cacheItemMock = $this->getCacheItemMock();
397
        $this->cacheMock
398
            ->expects($this->at(0))
399
            ->method('getItem')
400
            ->with('content', 'locations', '44', 'root', '2')
401
            ->will($this->returnValue($cacheItemMock));
402
403
        $cacheItemMock
404
            ->expects($this->once())
405
            ->method('get')
406
            ->will($this->returnValue([33]));
407
408
        $cacheItemMock
409
            ->expects($this->once())
410
            ->method('isMiss')
411
            ->will($this->returnValue(false));
412
413
        $cacheItemMock
414
            ->expects($this->never())
415
            ->method('set');
416
417
        // inline call to load()
418
        $cacheItemMock2 = $this->getCacheItemMock();
419
        $this->cacheMock
420
            ->expects($this->at(1))
421
            ->method('getItem')
422
            ->with('location', 33)
423
            ->will($this->returnValue($cacheItemMock2));
424
425
        $cacheItemMock2
426
            ->expects($this->once())
427
            ->method('get')
428
            ->will($this->returnValue(new Location(['id' => 33])));
429
430
        $cacheItemMock2
431
            ->expects($this->once())
432
            ->method('isMiss')
433
            ->will($this->returnValue(false));
434
435
        $cacheItemMock2
436
            ->expects($this->never())
437
            ->method('set');
438
439
        $handler = $this->persistenceCacheHandler->locationHandler();
440
        $handler->loadLocationsByContent(44, 2);
441
    }
442
443
    /**
444
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadByRemoteId

eZ/Publish/Core/Persistence/Cache/Tests/UrlAliasHandlerTest.php 1 location

@@ 826-878 (lines=53) @@
823
    /**
824
     * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::lookup
825
     */
826
    public function testLookupHasCache()
827
    {
828
        $this->loggerMock->expects($this->never())->method('logCall');
829
830
        $this->persistenceHandlerMock
831
            ->expects($this->never())
832
            ->method($this->anything());
833
834
        $cacheItemMock = $this->getCacheItemMock();
835
        $this->cacheMock
836
            ->expects($this->at(0))
837
            ->method('getItem')
838
            ->with('urlAlias', 'url', '/url')
839
            ->will($this->returnValue($cacheItemMock));
840
841
        $cacheItemMock
842
            ->expects($this->once())
843
            ->method('get')
844
            ->will($this->returnValue(55));
845
846
        $cacheItemMock
847
            ->expects($this->once())
848
            ->method('isMiss')
849
            ->will($this->returnValue(false));
850
851
        $cacheItemMock
852
            ->expects($this->never())
853
            ->method('set');
854
855
        $cacheItemMock2 = $this->getCacheItemMock();
856
        $this->cacheMock
857
            ->expects($this->at(1))
858
            ->method('getItem')
859
            ->with('urlAlias', 55)
860
            ->will($this->returnValue($cacheItemMock2));
861
862
        $cacheItemMock2
863
            ->expects($this->once())
864
            ->method('get')
865
            ->will($this->returnValue(new UrlAlias(['id' => 55])));
866
867
        $cacheItemMock2
868
            ->expects($this->once())
869
            ->method('isMiss')
870
            ->will($this->returnValue(false));
871
872
        $cacheItemMock2
873
            ->expects($this->never())
874
            ->method('set');
875
876
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
877
        $handler->lookup('/url');
878
    }
879
880
    /**
881
     * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::lookup