Code Duplication    Length = 41-50 lines in 2 locations

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

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