Code Duplication    Length = 40-40 lines in 2 locations

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

@@ 2215-2254 (lines=40) @@
2212
     * @group create
2213
     * @group custom
2214
     */
2215
    public function testCreateCustomUrlAliasReusesHistory()
2216
    {
2217
        $handler = $this->getHandler();
2218
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_reusing.php');
2219
2220
        $countBeforeReusing = $this->countRows();
2221
        $handler->createCustomUrlAlias(
2222
            314,
2223
            'history-hello',
2224
            true,
2225
            'eng-GB',
2226
            true
2227
        );
2228
2229
        self::assertEquals(
2230
            $countBeforeReusing,
2231
            $this->countRows()
2232
        );
2233
        self::assertEquals(
2234
            new UrlAlias(
2235
                [
2236
                    'id' => '0-da94285592c46d4396d3ca6904a4aa8f',
2237
                    'type' => UrlAlias::LOCATION,
2238
                    'destination' => 314,
2239
                    'languageCodes' => ['eng-GB'],
2240
                    'pathData' => [
2241
                        [
2242
                            'always-available' => true,
2243
                            'translations' => ['eng-GB' => 'history-hello'],
2244
                        ],
2245
                    ],
2246
                    'alwaysAvailable' => true,
2247
                    'isHistory' => false,
2248
                    'isCustom' => true,
2249
                    'forward' => true,
2250
                ]
2251
            ),
2252
            $handler->lookup('history-hello')
2253
        );
2254
    }
2255
2256
    /**
2257
     * Test for the createUrlAlias() method.
@@ 2314-2353 (lines=40) @@
2311
     * @group create
2312
     * @group custom
2313
     */
2314
    public function testCreateCustomUrlAliasReusesHistoryOfDifferentLanguage()
2315
    {
2316
        $handler = $this->getHandler();
2317
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_reusing.php');
2318
2319
        $countBeforeReusing = $this->countRows();
2320
        $handler->createCustomUrlAlias(
2321
            314,
2322
            'history-hello',
2323
            true,
2324
            'cro-HR',
2325
            true
2326
        );
2327
2328
        self::assertEquals(
2329
            $countBeforeReusing,
2330
            $this->countRows()
2331
        );
2332
        self::assertEquals(
2333
            new UrlAlias(
2334
                [
2335
                    'id' => '0-da94285592c46d4396d3ca6904a4aa8f',
2336
                    'type' => UrlAlias::LOCATION,
2337
                    'destination' => 314,
2338
                    'languageCodes' => ['cro-HR'],
2339
                    'pathData' => [
2340
                        [
2341
                            'always-available' => true,
2342
                            'translations' => ['cro-HR' => 'history-hello'],
2343
                        ],
2344
                    ],
2345
                    'alwaysAvailable' => true,
2346
                    'isHistory' => false,
2347
                    'isCustom' => true,
2348
                    'forward' => true,
2349
                ]
2350
            ),
2351
            $handler->lookup('history-hello')
2352
        );
2353
    }
2354
2355
    /**
2356
     * Test for the createUrlAlias() method.