Code Duplication    Length = 58-64 lines in 2 locations

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

@@ 726-783 (lines=58) @@
723
    /**
724
     * Test for the load() method.
725
     */
726
    public function testListLocationAliasesWithShowAllTranslations()
727
    {
728
        $pathElement1 = array(
729
            'always-available' => true,
730
            'translations' => array(
731
                'cro-HR' => 'jedan',
732
            ),
733
        );
734
        $pathElement2 = array(
735
            'always-available' => false,
736
            'translations' => array(
737
                'cro-HR' => 'dva',
738
                'eng-GB' => 'two',
739
            ),
740
        );
741
        $pathElement3 = array(
742
            'always-available' => false,
743
            'translations' => array(
744
                'cro-HR' => 'tri',
745
                'eng-GB' => 'three',
746
                'ger-DE' => 'drei',
747
            ),
748
        );
749
        $spiUrlAlias = new SPIUrlAlias(
750
            array(
751
                'id' => '3',
752
                'pathData' => array($pathElement1, $pathElement2, $pathElement3),
753
                'languageCodes' => array('ger-DE'),
754
                'alwaysAvailable' => false,
755
            )
756
        );
757
        $urlAliasService = $this->getRepository()->getURLAliasService();
758
        $configuration = array(
759
            'prioritizedLanguageList' => array('fre-FR'),
760
            'showAllTranslations' => true,
761
        );
762
        $this->setConfiguration($urlAliasService, $configuration);
763
764
        $urlAliasHandlerMock = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
765
766
        $urlAliasHandlerMock->expects(
767
            $this->once()
768
        )->method(
769
            'listURLAliasesForLocation'
770
        )->with(
771
            $this->equalTo(42),
772
            $this->equalTo(false)
773
        )->will(
774
            $this->returnValue(array($spiUrlAlias))
775
        );
776
777
        $location = $this->getLocationStub();
778
        $urlAliases = $urlAliasService->listLocationAliases($location, false, null);
779
780
        self::assertCount(1, $urlAliases);
781
        self::assertInstanceOf(URLAlias::class, $urlAliases[0]);
782
        self::assertEquals('/jedan/dva/tri', $urlAliases[0]->path);
783
    }
784
785
    /**
786
     * Test for the load() method.
@@ 788-851 (lines=64) @@
785
    /**
786
     * Test for the load() method.
787
     */
788
    public function testListLocationAliasesWithShowAllTranslationsCustomConfiguration()
789
    {
790
        $pathElement1 = array(
791
            'always-available' => true,
792
            'translations' => array(
793
                'cro-HR' => 'jedan',
794
            ),
795
        );
796
        $pathElement2 = array(
797
            'always-available' => false,
798
            'translations' => array(
799
                'cro-HR' => 'dva',
800
                'eng-GB' => 'two',
801
            ),
802
        );
803
        $pathElement3 = array(
804
            'always-available' => false,
805
            'translations' => array(
806
                'cro-HR' => 'tri',
807
                'eng-GB' => 'three',
808
                'ger-DE' => 'drei',
809
            ),
810
        );
811
        $spiUrlAlias = new SPIUrlAlias(
812
            array(
813
                'id' => '3',
814
                'pathData' => array($pathElement1, $pathElement2, $pathElement3),
815
                'languageCodes' => array('ger-DE'),
816
                'alwaysAvailable' => false,
817
            )
818
        );
819
        $urlAliasService = $this->getRepository()->getURLAliasService();
820
        $configuration = array(
821
            'prioritizedLanguageList' => array(),
822
            'showAllTranslations' => false,
823
        );
824
        $this->setConfiguration($urlAliasService, $configuration);
825
826
        $urlAliasHandlerMock = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
827
828
        $urlAliasHandlerMock->expects(
829
            $this->once()
830
        )->method(
831
            'listURLAliasesForLocation'
832
        )->with(
833
            $this->equalTo(42),
834
            $this->equalTo(false)
835
        )->will(
836
            $this->returnValue(array($spiUrlAlias))
837
        );
838
839
        $location = $this->getLocationStub();
840
        $urlAliases = $urlAliasService->listLocationAliases(
841
            $location,
842
            false,
843
            null,
844
            true,
845
            array('fre-FR')
846
        );
847
848
        self::assertCount(1, $urlAliases);
849
        self::assertInstanceOf(URLAlias::class, $urlAliases[0]);
850
        self::assertEquals('/jedan/dva/tri', $urlAliases[0]->path);
851
    }
852
853
    public function providerForTestListAutogeneratedLocationAliasesEmpty()
854
    {