Code Duplication    Length = 58-64 lines in 2 locations

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

@@ 768-825 (lines=58) @@
765
    /**
766
     * Test for the load() method.
767
     */
768
    public function testListLocationAliasesWithShowAllTranslations()
769
    {
770
        $pathElement1 = array(
771
            'always-available' => true,
772
            'translations' => array(
773
                'cro-HR' => 'jedan',
774
            ),
775
        );
776
        $pathElement2 = array(
777
            'always-available' => false,
778
            'translations' => array(
779
                'cro-HR' => 'dva',
780
                'eng-GB' => 'two',
781
            ),
782
        );
783
        $pathElement3 = array(
784
            'always-available' => false,
785
            'translations' => array(
786
                'cro-HR' => 'tri',
787
                'eng-GB' => 'three',
788
                'ger-DE' => 'drei',
789
            ),
790
        );
791
        $spiUrlAlias = new SPIUrlAlias(
792
            array(
793
                'id' => '3',
794
                'pathData' => array($pathElement1, $pathElement2, $pathElement3),
795
                'languageCodes' => array('ger-DE'),
796
                'alwaysAvailable' => false,
797
            )
798
        );
799
        $urlAliasService = $this->getRepository()->getURLAliasService();
800
        $configuration = array(
801
            'prioritizedLanguageList' => array('fre-FR'),
802
            'showAllTranslations' => true,
803
        );
804
        $this->setConfiguration($urlAliasService, $configuration);
805
806
        $urlAliasHandlerMock = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
807
808
        $urlAliasHandlerMock->expects(
809
            $this->once()
810
        )->method(
811
            'listURLAliasesForLocation'
812
        )->with(
813
            $this->equalTo(42),
814
            $this->equalTo(false)
815
        )->will(
816
            $this->returnValue(array($spiUrlAlias))
817
        );
818
819
        $location = $this->getLocationStub();
820
        $urlAliases = $urlAliasService->listLocationAliases($location, false, null);
821
822
        self::assertCount(1, $urlAliases);
823
        self::assertInstanceOf(URLAlias::class, $urlAliases[0]);
824
        self::assertEquals('/jedan/dva/tri', $urlAliases[0]->path);
825
    }
826
827
    /**
828
     * Test for the load() method.
@@ 830-893 (lines=64) @@
827
    /**
828
     * Test for the load() method.
829
     */
830
    public function testListLocationAliasesWithShowAllTranslationsCustomConfiguration()
831
    {
832
        $pathElement1 = array(
833
            'always-available' => true,
834
            'translations' => array(
835
                'cro-HR' => 'jedan',
836
            ),
837
        );
838
        $pathElement2 = array(
839
            'always-available' => false,
840
            'translations' => array(
841
                'cro-HR' => 'dva',
842
                'eng-GB' => 'two',
843
            ),
844
        );
845
        $pathElement3 = array(
846
            'always-available' => false,
847
            'translations' => array(
848
                'cro-HR' => 'tri',
849
                'eng-GB' => 'three',
850
                'ger-DE' => 'drei',
851
            ),
852
        );
853
        $spiUrlAlias = new SPIUrlAlias(
854
            array(
855
                'id' => '3',
856
                'pathData' => array($pathElement1, $pathElement2, $pathElement3),
857
                'languageCodes' => array('ger-DE'),
858
                'alwaysAvailable' => false,
859
            )
860
        );
861
        $urlAliasService = $this->getRepository()->getURLAliasService();
862
        $configuration = array(
863
            'prioritizedLanguageList' => array(),
864
            'showAllTranslations' => false,
865
        );
866
        $this->setConfiguration($urlAliasService, $configuration);
867
868
        $urlAliasHandlerMock = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
869
870
        $urlAliasHandlerMock->expects(
871
            $this->once()
872
        )->method(
873
            'listURLAliasesForLocation'
874
        )->with(
875
            $this->equalTo(42),
876
            $this->equalTo(false)
877
        )->will(
878
            $this->returnValue(array($spiUrlAlias))
879
        );
880
881
        $location = $this->getLocationStub();
882
        $urlAliases = $urlAliasService->listLocationAliases(
883
            $location,
884
            false,
885
            null,
886
            true,
887
            array('fre-FR')
888
        );
889
890
        self::assertCount(1, $urlAliases);
891
        self::assertInstanceOf(URLAlias::class, $urlAliases[0]);
892
        self::assertEquals('/jedan/dva/tri', $urlAliases[0]->path);
893
    }
894
895
    public function providerForTestListAutogeneratedLocationAliasesEmpty()
896
    {