Code Duplication    Length = 58-64 lines in 2 locations

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

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