Code Duplication    Length = 25-34 lines in 11 locations

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

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