Code Duplication    Length = 25-34 lines in 11 locations

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

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