Code Duplication    Length = 76-76 lines in 2 locations

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

@@ 488-563 (lines=76) @@
485
    /**
486
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation
487
     */
488
    public function testListURLAliasesForLocationHasCache()
489
    {
490
        $this->loggerMock->expects($this->never())->method('logCall');
491
492
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
493
        $this->cacheMock
494
            ->expects($this->at(0))
495
            ->method('getItem')
496
            ->with('urlAlias', 'location', 44)
497
            ->will($this->returnValue($cacheItemMock));
498
499
        $cacheItemMock
500
            ->expects($this->once())
501
            ->method('get')
502
            ->will($this->returnValue(array(55, 58, 91)));
503
504
        $cacheItemMock
505
            ->expects($this->once())
506
            ->method('isMiss')
507
            ->will($this->returnValue(false));
508
509
        $this->persistenceHandlerMock
510
            ->expects($this->never())
511
            ->method($this->anything());
512
513
        $cacheItemMock
514
            ->expects($this->never())
515
            ->method('set');
516
517
        // inline calls to loadUrlAlias() using the cache
518
        $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface');
519
        $this->cacheMock
520
            ->expects($this->at(1))
521
            ->method('getItem')
522
            ->with('urlAlias', 55)
523
            ->will($this->returnValue($cacheItemMock2));
524
525
        $cacheItemMock2
526
            ->expects($this->at(0))
527
            ->method('get')
528
            ->will($this->returnValue(new UrlAlias(array('id' => 55))));
529
530
        $this->cacheMock
531
            ->expects($this->at(2))
532
            ->method('getItem')
533
            ->with('urlAlias', 58)
534
            ->will($this->returnValue($cacheItemMock2));
535
536
        $cacheItemMock2
537
            ->expects($this->at(1))
538
            ->method('get')
539
            ->will($this->returnValue(new UrlAlias(array('id' => 58))));
540
541
        $this->cacheMock
542
            ->expects($this->at(3))
543
            ->method('getItem')
544
            ->with('urlAlias', 91)
545
            ->will($this->returnValue($cacheItemMock2));
546
547
        $cacheItemMock2
548
            ->expects($this->at(2))
549
            ->method('get')
550
            ->will($this->returnValue(new UrlAlias(array('id' => 91))));
551
552
        $cacheItemMock2
553
            ->expects($this->exactly(3))
554
            ->method('isMiss')
555
            ->will($this->returnValue(false));
556
557
        $cacheItemMock2
558
            ->expects($this->never())
559
            ->method('set');
560
561
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
562
        $handler->listURLAliasesForLocation(44, false);
563
    }
564
565
    /**
566
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation
@@ 568-643 (lines=76) @@
565
    /**
566
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::listURLAliasesForLocation
567
     */
568
    public function testListURLAliasesForLocationCustomHasCache()
569
    {
570
        $this->loggerMock->expects($this->never())->method('logCall');
571
572
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
573
        $this->cacheMock
574
            ->expects($this->at(0))
575
            ->method('getItem')
576
            ->with('urlAlias', 'location', '44', 'custom')
577
            ->will($this->returnValue($cacheItemMock));
578
579
        $cacheItemMock
580
            ->expects($this->once())
581
            ->method('get')
582
            ->will($this->returnValue(array(55, 58, 91)));
583
584
        $cacheItemMock
585
            ->expects($this->once())
586
            ->method('isMiss')
587
            ->will($this->returnValue(false));
588
589
        $this->persistenceHandlerMock
590
            ->expects($this->never())
591
            ->method($this->anything());
592
593
        $cacheItemMock
594
            ->expects($this->never())
595
            ->method('set');
596
597
                // inline calls to loadUrlAlias() using the cache
598
        $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface');
599
        $this->cacheMock
600
            ->expects($this->at(1))
601
            ->method('getItem')
602
            ->with('urlAlias', 55)
603
            ->will($this->returnValue($cacheItemMock2));
604
605
        $cacheItemMock2
606
            ->expects($this->at(0))
607
            ->method('get')
608
            ->will($this->returnValue(new UrlAlias(array('id' => 55))));
609
610
        $this->cacheMock
611
            ->expects($this->at(2))
612
            ->method('getItem')
613
            ->with('urlAlias', 58)
614
            ->will($this->returnValue($cacheItemMock2));
615
616
        $cacheItemMock2
617
            ->expects($this->at(1))
618
            ->method('get')
619
            ->will($this->returnValue(new UrlAlias(array('id' => 58))));
620
621
        $this->cacheMock
622
            ->expects($this->at(3))
623
            ->method('getItem')
624
            ->with('urlAlias', 91)
625
            ->will($this->returnValue($cacheItemMock2));
626
627
        $cacheItemMock2
628
            ->expects($this->at(2))
629
            ->method('get')
630
            ->will($this->returnValue(new UrlAlias(array('id' => 91))));
631
632
        $cacheItemMock2
633
            ->expects($this->exactly(3))
634
            ->method('isMiss')
635
            ->will($this->returnValue(false));
636
637
        $cacheItemMock2
638
            ->expects($this->never())
639
            ->method('set');
640
641
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
642
        $handler->listURLAliasesForLocation(44, true);
643
    }
644
645
    /**
646
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::removeURLAliases