Code Duplication    Length = 25-34 lines in 11 locations

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

@@ 936-960 (lines=25) @@
933
     *
934
     * @dataProvider providerForTestListAutogeneratedLocationAliasesEmpty
935
     */
936
    public function testListAutogeneratedLocationAliasesEmpty($spiUrlAliases, $prioritizedLanguageCodes)
937
    {
938
        $urlAliasService = $this->getRepository()->getURLAliasService();
939
        $configuration = array(
940
            'prioritizedLanguageList' => $prioritizedLanguageCodes,
941
            'showAllTranslations' => false,
942
        );
943
        $this->setConfiguration($urlAliasService, $configuration);
944
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
945
        $urlAliasHandler->expects(
946
            $this->once()
947
        )->method(
948
            'listURLAliasesForLocation'
949
        )->with(
950
            $this->equalTo(42),
951
            $this->equalTo(false)
952
        )->will(
953
            $this->returnValue($spiUrlAliases)
954
        );
955
956
        $location = $this->getLocationStub();
957
        $urlAliases = $urlAliasService->listLocationAliases($location, false, null);
958
959
        self::assertEmpty($urlAliases);
960
    }
961
962
    /**
963
     * Test for the listLocationAliases() method.
@@ 967-999 (lines=33) @@
964
     *
965
     * @dataProvider providerForTestListAutogeneratedLocationAliasesEmpty
966
     */
967
    public function testListAutogeneratedLocationAliasesEmptyCustomConfiguration(
968
        $spiUrlAliases,
969
        $prioritizedLanguageCodes
970
    ) {
971
        $urlAliasService = $this->getRepository()->getURLAliasService();
972
        $configuration = array(
973
            'prioritizedLanguageList' => array(),
974
            'showAllTranslations' => false,
975
        );
976
        $this->setConfiguration($urlAliasService, $configuration);
977
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
978
        $urlAliasHandler->expects(
979
            $this->once()
980
        )->method(
981
            'listURLAliasesForLocation'
982
        )->with(
983
            $this->equalTo(42),
984
            $this->equalTo(false)
985
        )->will(
986
            $this->returnValue($spiUrlAliases)
987
        );
988
989
        $location = $this->getLocationStub();
990
        $urlAliases = $urlAliasService->listLocationAliases(
991
            $location,
992
            false,
993
            null,
994
            false,
995
            $prioritizedLanguageCodes
996
        );
997
998
        self::assertEmpty($urlAliases);
999
    }
1000
1001
    public function providerForTestListAutogeneratedLocationAliasesWithLanguageCodePath()
1002
    {
@@ 1610-1637 (lines=28) @@
1607
     *
1608
     * @dataProvider providerForTestListAutogeneratedLocationAliasesWithLanguageCodeEmpty
1609
     */
1610
    public function testListAutogeneratedLocationAliasesWithLanguageCodeEmpty(
1611
        $spiUrlAliases,
1612
        $languageCode,
1613
        $prioritizedLanguageCodes
1614
    ) {
1615
        $urlAliasService = $this->getRepository()->getURLAliasService();
1616
        $configuration = array(
1617
            'prioritizedLanguageList' => $prioritizedLanguageCodes,
1618
            'showAllTranslations' => false,
1619
        );
1620
        $this->setConfiguration($urlAliasService, $configuration);
1621
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
1622
        $urlAliasHandler->expects(
1623
            $this->once()
1624
        )->method(
1625
            'listURLAliasesForLocation'
1626
        )->with(
1627
            $this->equalTo(42),
1628
            $this->equalTo(false)
1629
        )->will(
1630
            $this->returnValue($spiUrlAliases)
1631
        );
1632
1633
        $location = $this->getLocationStub();
1634
        $urlAliases = $urlAliasService->listLocationAliases($location, false, $languageCode);
1635
1636
        self::assertEmpty($urlAliases);
1637
    }
1638
1639
    /**
1640
     * Test for the listLocationAliases() method.
@@ 1644-1677 (lines=34) @@
1641
     *
1642
     * @dataProvider providerForTestListAutogeneratedLocationAliasesWithLanguageCodeEmpty
1643
     */
1644
    public function testListAutogeneratedLocationAliasesWithLanguageCodeEmptyCustomConfiguration(
1645
        $spiUrlAliases,
1646
        $languageCode,
1647
        $prioritizedLanguageCodes
1648
    ) {
1649
        $urlAliasService = $this->getRepository()->getURLAliasService();
1650
        $configuration = array(
1651
            'prioritizedLanguageList' => array(),
1652
            'showAllTranslations' => false,
1653
        );
1654
        $this->setConfiguration($urlAliasService, $configuration);
1655
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
1656
        $urlAliasHandler->expects(
1657
            $this->once()
1658
        )->method(
1659
            'listURLAliasesForLocation'
1660
        )->with(
1661
            $this->equalTo(42),
1662
            $this->equalTo(false)
1663
        )->will(
1664
            $this->returnValue($spiUrlAliases)
1665
        );
1666
1667
        $location = $this->getLocationStub();
1668
        $urlAliases = $urlAliasService->listLocationAliases(
1669
            $location,
1670
            false,
1671
            $languageCode,
1672
            false,
1673
            $prioritizedLanguageCodes
1674
        );
1675
1676
        self::assertEmpty($urlAliases);
1677
    }
1678
1679
    public function providerForTestListAutogeneratedLocationAliasesMultipleLanguagesPath()
1680
    {
@@ 1873-1897 (lines=25) @@
1870
     *
1871
     * @dataProvider providerForTestListAutogeneratedLocationAliasesMultipleLanguagesEmpty
1872
     */
1873
    public function testListAutogeneratedLocationAliasesMultipleLanguagesEmpty($spiUrlAliases, $prioritizedLanguageCodes)
1874
    {
1875
        $urlAliasService = $this->getRepository()->getURLAliasService();
1876
        $configuration = array(
1877
            'prioritizedLanguageList' => $prioritizedLanguageCodes,
1878
            'showAllTranslations' => false,
1879
        );
1880
        $this->setConfiguration($urlAliasService, $configuration);
1881
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
1882
        $urlAliasHandler->expects(
1883
            $this->once()
1884
        )->method(
1885
            'listURLAliasesForLocation'
1886
        )->with(
1887
            $this->equalTo(42),
1888
            $this->equalTo(false)
1889
        )->will(
1890
            $this->returnValue($spiUrlAliases)
1891
        );
1892
1893
        $location = $this->getLocationStub();
1894
        $urlAliases = $urlAliasService->listLocationAliases($location, false, null);
1895
1896
        self::assertEmpty($urlAliases);
1897
    }
1898
1899
    /**
1900
     * Test for the listLocationAliases() method.
@@ 1904-1936 (lines=33) @@
1901
     *
1902
     * @dataProvider providerForTestListAutogeneratedLocationAliasesMultipleLanguagesEmpty
1903
     */
1904
    public function testListAutogeneratedLocationAliasesMultipleLanguagesEmptyCustomConfiguration(
1905
        $spiUrlAliases,
1906
        $prioritizedLanguageCodes
1907
    ) {
1908
        $urlAliasService = $this->getRepository()->getURLAliasService();
1909
        $configuration = array(
1910
            'prioritizedLanguageList' => array(),
1911
            'showAllTranslations' => false,
1912
        );
1913
        $this->setConfiguration($urlAliasService, $configuration);
1914
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
1915
        $urlAliasHandler->expects(
1916
            $this->once()
1917
        )->method(
1918
            'listURLAliasesForLocation'
1919
        )->with(
1920
            $this->equalTo(42),
1921
            $this->equalTo(false)
1922
        )->will(
1923
            $this->returnValue($spiUrlAliases)
1924
        );
1925
1926
        $location = $this->getLocationStub();
1927
        $urlAliases = $urlAliasService->listLocationAliases(
1928
            $location,
1929
            false,
1930
            null,
1931
            false,
1932
            $prioritizedLanguageCodes
1933
        );
1934
1935
        self::assertEmpty($urlAliases);
1936
    }
1937
1938
    public function providerForTestListAutogeneratedLocationAliasesWithLanguageCodeMultipleLanguagesPath()
1939
    {
@@ 2153-2180 (lines=28) @@
2150
     *
2151
     * @dataProvider providerForTestListAutogeneratedLocationAliasesWithLanguageCodeMultipleLanguagesEmpty
2152
     */
2153
    public function testListAutogeneratedLocationAliasesWithLanguageCodeMultipleLanguagesEmpty(
2154
        $spiUrlAliases,
2155
        $languageCode,
2156
        $prioritizedLanguageCodes
2157
    ) {
2158
        $urlAliasService = $this->getRepository()->getURLAliasService();
2159
        $configuration = array(
2160
            'prioritizedLanguageList' => $prioritizedLanguageCodes,
2161
            'showAllTranslations' => false,
2162
        );
2163
        $this->setConfiguration($urlAliasService, $configuration);
2164
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
2165
        $urlAliasHandler->expects(
2166
            $this->once()
2167
        )->method(
2168
            'listURLAliasesForLocation'
2169
        )->with(
2170
            $this->equalTo(42),
2171
            $this->equalTo(false)
2172
        )->will(
2173
            $this->returnValue($spiUrlAliases)
2174
        );
2175
2176
        $location = $this->getLocationStub();
2177
        $urlAliases = $urlAliasService->listLocationAliases($location, false, $languageCode);
2178
2179
        self::assertEmpty($urlAliases);
2180
    }
2181
2182
    /**
2183
     * Test for the listLocationAliases() method.
@@ 2187-2220 (lines=34) @@
2184
     *
2185
     * @dataProvider providerForTestListAutogeneratedLocationAliasesWithLanguageCodeMultipleLanguagesEmpty
2186
     */
2187
    public function testListAutogeneratedLocationAliasesWithLanguageCodeMultipleLanguagesEmptyCustomConfiguration(
2188
        $spiUrlAliases,
2189
        $languageCode,
2190
        $prioritizedLanguageCodes
2191
    ) {
2192
        $urlAliasService = $this->getRepository()->getURLAliasService();
2193
        $configuration = array(
2194
            'prioritizedLanguageList' => array(),
2195
            'showAllTranslations' => false,
2196
        );
2197
        $this->setConfiguration($urlAliasService, $configuration);
2198
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
2199
        $urlAliasHandler->expects(
2200
            $this->once()
2201
        )->method(
2202
            'listURLAliasesForLocation'
2203
        )->with(
2204
            $this->equalTo(42),
2205
            $this->equalTo(false)
2206
        )->will(
2207
            $this->returnValue($spiUrlAliases)
2208
        );
2209
2210
        $location = $this->getLocationStub();
2211
        $urlAliases = $urlAliasService->listLocationAliases(
2212
            $location,
2213
            false,
2214
            $languageCode,
2215
            false,
2216
            $prioritizedLanguageCodes
2217
        );
2218
2219
        self::assertEmpty($urlAliases);
2220
    }
2221
2222
    public function providerForTestListAutogeneratedLocationAliasesAlwaysAvailablePath()
2223
    {
@@ 2573-2600 (lines=28) @@
2570
     *
2571
     * @dataProvider providerForTestListAutogeneratedLocationAliasesWithLanguageCodeAlwaysAvailableEmpty
2572
     */
2573
    public function testListAutogeneratedLocationAliasesWithLanguageCodeAlwaysAvailableEmpty(
2574
        $spiUrlAliases,
2575
        $languageCode,
2576
        $prioritizedLanguageCodes
2577
    ) {
2578
        $urlAliasService = $this->getRepository()->getURLAliasService();
2579
        $configuration = array(
2580
            'prioritizedLanguageList' => $prioritizedLanguageCodes,
2581
            'showAllTranslations' => false,
2582
        );
2583
        $this->setConfiguration($urlAliasService, $configuration);
2584
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
2585
        $urlAliasHandler->expects(
2586
            $this->once()
2587
        )->method(
2588
            'listURLAliasesForLocation'
2589
        )->with(
2590
            $this->equalTo(42),
2591
            $this->equalTo(false)
2592
        )->will(
2593
            $this->returnValue($spiUrlAliases)
2594
        );
2595
2596
        $location = $this->getLocationStub();
2597
        $urlAliases = $urlAliasService->listLocationAliases($location, false, $languageCode);
2598
2599
        self::assertEmpty($urlAliases);
2600
    }
2601
2602
    /**
2603
     * Test for the listLocationAliases() method.
@@ 2607-2640 (lines=34) @@
2604
     *
2605
     * @dataProvider providerForTestListAutogeneratedLocationAliasesWithLanguageCodeAlwaysAvailableEmpty
2606
     */
2607
    public function testListAutogeneratedLocationAliasesWithLanguageCodeAlwaysAvailableEmptyCustomConfiguration(
2608
        $spiUrlAliases,
2609
        $languageCode,
2610
        $prioritizedLanguageCodes
2611
    ) {
2612
        $urlAliasService = $this->getRepository()->getURLAliasService();
2613
        $configuration = array(
2614
            'prioritizedLanguageList' => array(),
2615
            'showAllTranslations' => false,
2616
        );
2617
        $this->setConfiguration($urlAliasService, $configuration);
2618
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
2619
        $urlAliasHandler->expects(
2620
            $this->once()
2621
        )->method(
2622
            'listURLAliasesForLocation'
2623
        )->with(
2624
            $this->equalTo(42),
2625
            $this->equalTo(false)
2626
        )->will(
2627
            $this->returnValue($spiUrlAliases)
2628
        );
2629
2630
        $location = $this->getLocationStub();
2631
        $urlAliases = $urlAliasService->listLocationAliases(
2632
            $location,
2633
            false,
2634
            $languageCode,
2635
            false,
2636
            $prioritizedLanguageCodes
2637
        );
2638
2639
        self::assertEmpty($urlAliases);
2640
    }
2641
2642
    /**
2643
     * Test for the listGlobalAliases() method.
@@ 3117-3147 (lines=31) @@
3114
     *
3115
     * @dataProvider providerForTestReverseLookupAlwaysAvailablePath
3116
     */
3117
    public function testReverseLookupAlwaysAvailablePath(
3118
        $spiUrlAliases,
3119
        $prioritizedLanguageCodes,
3120
        $paths
3121
    ) {
3122
        $urlAliasService = $this->getRepository()->getURLAliasService();
3123
        $configuration = array(
3124
            'prioritizedLanguageList' => $prioritizedLanguageCodes,
3125
            'showAllTranslations' => false,
3126
        );
3127
        $this->setConfiguration($urlAliasService, $configuration);
3128
        $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler');
3129
        $urlAliasHandler->expects(
3130
            $this->once()
3131
        )->method(
3132
            'listURLAliasesForLocation'
3133
        )->with(
3134
            $this->equalTo(42),
3135
            $this->equalTo(false)
3136
        )->will(
3137
            $this->returnValue($spiUrlAliases)
3138
        );
3139
3140
        $location = $this->getLocationStub();
3141
        $urlAlias = $urlAliasService->reverseLookup($location);
3142
3143
        self::assertEquals(
3144
            reset($paths),
3145
            $urlAlias->path
3146
        );
3147
    }
3148
3149
    /**
3150
     * Test for the reverseLookup() method.