Code Duplication    Length = 58-59 lines in 2 locations

eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/UrlAliasHandlerTest.php 2 locations

@@ 1790-1847 (lines=58) @@
1787
     * @group cleanup
1788
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation
1789
     */
1790
    public function testPublishUrlAliasReuseHistoryCleanup()
1791
    {
1792
        $handler = $this->getHandler();
1793
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_cleanup_history.php');
1794
1795
        $handler->publishUrlAliasForLocation(314, 2, 'tri', 'cro-HR', false);
1796
1797
        $urlAlias = $handler->lookup('jedan');
1798
        $this->assertEquals(
1799
            new UrlAlias(
1800
                [
1801
                    'id' => '0-' . md5('jedan'),
1802
                    'type' => UrlAlias::LOCATION,
1803
                    'destination' => 314,
1804
                    'pathData' => [
1805
                        [
1806
                            'always-available' => false,
1807
                            'translations' => ['cro-HR' => 'jedan'],
1808
                        ],
1809
                    ],
1810
                    'languageCodes' => ['cro-HR'],
1811
                    'alwaysAvailable' => false,
1812
                    'isHistory' => true,
1813
                    'isCustom' => false,
1814
                    'forward' => false,
1815
                ]
1816
            ),
1817
            $urlAlias
1818
        );
1819
1820
        $urlAlias = $handler->lookup('tri');
1821
        $this->assertEquals(
1822
            new UrlAlias(
1823
                [
1824
                    'id' => '0-' . md5('tri'),
1825
                    'type' => UrlAlias::LOCATION,
1826
                    'destination' => 314,
1827
                    'pathData' => [
1828
                        [
1829
                            'always-available' => false,
1830
                            'translations' => [
1831
                                'cro-HR' => 'tri',
1832
                                'eng-GB' => 'dva',
1833
                            ],
1834
                        ],
1835
                    ],
1836
                    'languageCodes' => [
1837
                        'cro-HR',
1838
                    ],
1839
                    'alwaysAvailable' => false,
1840
                    'isHistory' => false,
1841
                    'isCustom' => false,
1842
                    'forward' => false,
1843
                ]
1844
            ),
1845
            $urlAlias
1846
        );
1847
    }
1848
1849
    /**
1850
     * Test for the publishUrlAliasForLocation() method.
@@ 1855-1913 (lines=59) @@
1852
     * @group cleanup
1853
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation
1854
     */
1855
    public function testPublishUrlAliasReuseAutogeneratedCleanup()
1856
    {
1857
        $handler = $this->getHandler();
1858
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_cleanup_reusing.php');
1859
1860
        $handler->publishUrlAliasForLocation(314, 2, 'dva', 'cro-HR', false);
1861
1862
        $urlAlias = $handler->lookup('jedan');
1863
        $this->assertEquals(
1864
            new UrlAlias(
1865
                [
1866
                    'id' => '0-' . md5('jedan'),
1867
                    'type' => UrlAlias::LOCATION,
1868
                    'destination' => 314,
1869
                    'pathData' => [
1870
                        [
1871
                            'always-available' => false,
1872
                            'translations' => ['cro-HR' => 'jedan'],
1873
                        ],
1874
                    ],
1875
                    'languageCodes' => ['cro-HR'],
1876
                    'alwaysAvailable' => false,
1877
                    'isHistory' => true,
1878
                    'isCustom' => false,
1879
                    'forward' => false,
1880
                ]
1881
            ),
1882
            $urlAlias
1883
        );
1884
1885
        $urlAlias = $handler->lookup('dva');
1886
        $this->assertEquals(
1887
            new UrlAlias(
1888
                [
1889
                    'id' => '0-' . md5('dva'),
1890
                    'type' => UrlAlias::LOCATION,
1891
                    'destination' => 314,
1892
                    'pathData' => [
1893
                        [
1894
                            'always-available' => false,
1895
                            'translations' => [
1896
                                'cro-HR' => 'dva',
1897
                                'eng-GB' => 'dva',
1898
                            ],
1899
                        ],
1900
                    ],
1901
                    'languageCodes' => [
1902
                        'cro-HR',
1903
                        'eng-GB',
1904
                    ],
1905
                    'alwaysAvailable' => false,
1906
                    'isHistory' => false,
1907
                    'isCustom' => false,
1908
                    'forward' => false,
1909
                ]
1910
            ),
1911
            $urlAlias
1912
        );
1913
    }
1914
1915
    /**
1916
     * Test for the createCustomUrlAlias() method.