Code Duplication    Length = 41-50 lines in 2 locations

eZ/Publish/Core/Repository/Tests/Service/Mock/UrlAliasTest.php 2 locations

@@ 626-666 (lines=41) @@
623
     *
624
     * @dataProvider providerForTestListAutogeneratedLocationAliasesPath
625
     */
626
    public function testListAutogeneratedLocationAliasesPath($spiUrlAliases, $prioritizedLanguageCodes, $paths)
627
    {
628
        $urlAliasService = $this->getRepository()->getURLAliasService();
629
        $configuration = array(
630
            'prioritizedLanguageList' => $prioritizedLanguageCodes,
631
            'showAllTranslations' => false,
632
        );
633
        $this->setConfiguration($urlAliasService, $configuration);
634
635
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
636
        $urlAliasHandler->expects(
637
            $this->once()
638
        )->method(
639
            'listURLAliasesForLocation'
640
        )->with(
641
            $this->equalTo(42),
642
            $this->equalTo(false)
643
        )->will(
644
            $this->returnValue($spiUrlAliases)
645
        );
646
647
        $location = $this->getLocationStub();
648
        $urlAliases = $urlAliasService->listLocationAliases($location, false, null);
649
650
        self::assertEquals(
651
            count($paths),
652
            count($urlAliases)
653
        );
654
655
        foreach ($urlAliases as $index => $urlAlias) {
656
            $pathKeys = array_keys($paths);
657
            self::assertEquals(
658
                $paths[$pathKeys[$index]],
659
                $urlAlias->path
660
            );
661
            self::assertEquals(
662
                array($pathKeys[$index]),
663
                $urlAlias->languageCodes
664
            );
665
        }
666
    }
667
668
    /**
669
     * Test for the listLocationAliases() method.
@@ 673-722 (lines=50) @@
670
     *
671
     * @dataProvider providerForTestListAutogeneratedLocationAliasesPath
672
     */
673
    public function testListAutogeneratedLocationAliasesPathCustomConfiguration(
674
        $spiUrlAliases,
675
        $prioritizedLanguageCodes,
676
        $paths
677
    ) {
678
        $urlAliasService = $this->getRepository()->getURLAliasService();
679
        $configuration = array(
680
            'prioritizedLanguageList' => array(),
681
            'showAllTranslations' => false,
682
        );
683
        $this->setConfiguration($urlAliasService, $configuration);
684
685
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
686
        $urlAliasHandler->expects(
687
            $this->once()
688
        )->method(
689
            'listURLAliasesForLocation'
690
        )->with(
691
            $this->equalTo(42),
692
            $this->equalTo(false)
693
        )->will(
694
            $this->returnValue($spiUrlAliases)
695
        );
696
697
        $location = $this->getLocationStub();
698
        $urlAliases = $urlAliasService->listLocationAliases(
699
            $location,
700
            false,
701
            null,
702
            false,
703
            $prioritizedLanguageCodes
704
        );
705
706
        self::assertEquals(
707
            count($paths),
708
            count($urlAliases)
709
        );
710
711
        foreach ($urlAliases as $index => $urlAlias) {
712
            $pathKeys = array_keys($paths);
713
            self::assertEquals(
714
                $paths[$pathKeys[$index]],
715
                $urlAlias->path
716
            );
717
            self::assertEquals(
718
                array($pathKeys[$index]),
719
                $urlAlias->languageCodes
720
            );
721
        }
722
    }
723
724
    /**
725
     * Test for the load() method.