Code Duplication    Length = 58-59 lines in 2 locations

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

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