Code Duplication    Length = 25-34 lines in 11 locations

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

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