Code Duplication    Length = 76-76 lines in 2 locations

eZ/Publish/Core/Persistence/Cache/Tests/UrlAliasHandlerTest.php 2 locations

@@ 378-453 (lines=76) @@
375
    /**
376
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation
377
     */
378
    public function testListURLAliasesForLocationHasCache()
379
    {
380
        $this->loggerMock->expects($this->never())->method('logCall');
381
382
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
383
        $this->cacheMock
384
            ->expects($this->at(0))
385
            ->method('getItem')
386
            ->with('urlAlias', 'location', 44)
387
            ->will($this->returnValue($cacheItemMock));
388
389
        $cacheItemMock
390
            ->expects($this->once())
391
            ->method('get')
392
            ->will($this->returnValue(array(55, 58, 91)));
393
394
        $cacheItemMock
395
            ->expects($this->once())
396
            ->method('isMiss')
397
            ->will($this->returnValue(false));
398
399
        $this->persistenceHandlerMock
400
            ->expects($this->never())
401
            ->method($this->anything());
402
403
        $cacheItemMock
404
            ->expects($this->never())
405
            ->method('set');
406
407
        // inline calls to loadUrlAlias() using the cache
408
        $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface');
409
        $this->cacheMock
410
            ->expects($this->at(1))
411
            ->method('getItem')
412
            ->with('urlAlias', 55)
413
            ->will($this->returnValue($cacheItemMock2));
414
415
        $cacheItemMock2
416
            ->expects($this->at(0))
417
            ->method('get')
418
            ->will($this->returnValue(new UrlAlias(array('id' => 55))));
419
420
        $this->cacheMock
421
            ->expects($this->at(2))
422
            ->method('getItem')
423
            ->with('urlAlias', 58)
424
            ->will($this->returnValue($cacheItemMock2));
425
426
        $cacheItemMock2
427
            ->expects($this->at(1))
428
            ->method('get')
429
            ->will($this->returnValue(new UrlAlias(array('id' => 58))));
430
431
        $this->cacheMock
432
            ->expects($this->at(3))
433
            ->method('getItem')
434
            ->with('urlAlias', 91)
435
            ->will($this->returnValue($cacheItemMock2));
436
437
        $cacheItemMock2
438
            ->expects($this->at(2))
439
            ->method('get')
440
            ->will($this->returnValue(new UrlAlias(array('id' => 91))));
441
442
        $cacheItemMock2
443
            ->expects($this->exactly(3))
444
            ->method('isMiss')
445
            ->will($this->returnValue(false));
446
447
        $cacheItemMock2
448
            ->expects($this->never())
449
            ->method('set');
450
451
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
452
        $handler->listURLAliasesForLocation(44, false);
453
    }
454
455
    /**
456
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation
@@ 458-533 (lines=76) @@
455
    /**
456
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation
457
     */
458
    public function testListURLAliasesForLocationCustomHasCache()
459
    {
460
        $this->loggerMock->expects($this->never())->method('logCall');
461
462
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
463
        $this->cacheMock
464
            ->expects($this->at(0))
465
            ->method('getItem')
466
            ->with('urlAlias', 'location', '44', 'custom')
467
            ->will($this->returnValue($cacheItemMock));
468
469
        $cacheItemMock
470
            ->expects($this->once())
471
            ->method('get')
472
            ->will($this->returnValue(array(55, 58, 91)));
473
474
        $cacheItemMock
475
            ->expects($this->once())
476
            ->method('isMiss')
477
            ->will($this->returnValue(false));
478
479
        $this->persistenceHandlerMock
480
            ->expects($this->never())
481
            ->method($this->anything());
482
483
        $cacheItemMock
484
            ->expects($this->never())
485
            ->method('set');
486
487
                // inline calls to loadUrlAlias() using the cache
488
        $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface');
489
        $this->cacheMock
490
            ->expects($this->at(1))
491
            ->method('getItem')
492
            ->with('urlAlias', 55)
493
            ->will($this->returnValue($cacheItemMock2));
494
495
        $cacheItemMock2
496
            ->expects($this->at(0))
497
            ->method('get')
498
            ->will($this->returnValue(new UrlAlias(array('id' => 55))));
499
500
        $this->cacheMock
501
            ->expects($this->at(2))
502
            ->method('getItem')
503
            ->with('urlAlias', 58)
504
            ->will($this->returnValue($cacheItemMock2));
505
506
        $cacheItemMock2
507
            ->expects($this->at(1))
508
            ->method('get')
509
            ->will($this->returnValue(new UrlAlias(array('id' => 58))));
510
511
        $this->cacheMock
512
            ->expects($this->at(3))
513
            ->method('getItem')
514
            ->with('urlAlias', 91)
515
            ->will($this->returnValue($cacheItemMock2));
516
517
        $cacheItemMock2
518
            ->expects($this->at(2))
519
            ->method('get')
520
            ->will($this->returnValue(new UrlAlias(array('id' => 91))));
521
522
        $cacheItemMock2
523
            ->expects($this->exactly(3))
524
            ->method('isMiss')
525
            ->will($this->returnValue(false));
526
527
        $cacheItemMock2
528
            ->expects($this->never())
529
            ->method('set');
530
531
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
532
        $handler->listURLAliasesForLocation(44, true);
533
    }
534
535
    /**
536
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::removeURLAliases