Code Duplication    Length = 58-59 lines in 2 locations

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

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