Code Duplication    Length = 25-34 lines in 11 locations

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

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