Code Duplication    Length = 58-59 lines in 2 locations

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

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