Code Duplication    Length = 41-50 lines in 2 locations

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

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