Code Duplication    Length = 24-29 lines in 4 locations

eZ/Publish/API/Repository/Tests/URLAliasServiceTest.php 4 locations

@@ 153-176 (lines=24) @@
150
     * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias($location, $path, $languageCode, $forwarding)
151
     * @depends testCreateUrlAliasPropertyValues
152
     */
153
    public function testCreateUrlAliasWithForwarding()
154
    {
155
        $repository = $this->getRepository();
156
157
        $locationId = $this->generateId('location', 5);
158
159
        /* BEGIN: Use Case */
160
        // $locationId is the ID of an existing location
161
162
        $locationService = $repository->getLocationService();
163
        $urlAliasService = $repository->getURLAliasService();
164
165
        $location = $locationService->loadLocation($locationId);
166
167
        $createdUrlAlias = $urlAliasService->createUrlAlias($location, '/Home/My-New-Site', 'eng-US', true);
168
        /* END: Use Case */
169
170
        $this->assertInstanceOf(
171
            URLAlias::class,
172
            $createdUrlAlias
173
        );
174
175
        return [$createdUrlAlias, $location->id];
176
    }
177
178
    /**
179
     * @param array $testData
@@ 209-232 (lines=24) @@
206
     *
207
     * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias($location, $path, $languageCode, $forwarding, $alwaysAvailable)
208
     */
209
    public function testCreateUrlAliasWithAlwaysAvailable()
210
    {
211
        $repository = $this->getRepository();
212
213
        $locationId = $this->generateId('location', 5);
214
215
        /* BEGIN: Use Case */
216
        // $locationId is the ID of an existing location
217
218
        $locationService = $repository->getLocationService();
219
        $urlAliasService = $repository->getURLAliasService();
220
221
        $location = $locationService->loadLocation($locationId);
222
223
        $createdUrlAlias = $urlAliasService->createUrlAlias($location, '/Home/My-New-Site', 'eng-US', false, true);
224
        /* END: Use Case */
225
226
        $this->assertInstanceOf(
227
            URLAlias::class,
228
            $createdUrlAlias
229
        );
230
231
        return [$createdUrlAlias, $location->id];
232
    }
233
234
    /**
235
     * @param array $testData
@@ 447-475 (lines=29) @@
444
     *
445
     * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable)
446
     */
447
    public function testCreateGlobalUrlAliasForLocation()
448
    {
449
        $repository = $this->getRepository();
450
451
        $locationId = $this->generateId('location', 5);
452
        $locationService = $repository->getLocationService();
453
        $location = $locationService->loadLocation($locationId);
454
455
        /* BEGIN: Use Case */
456
        // $locationId is the ID of an existing location
457
458
        $urlAliasService = $repository->getURLAliasService();
459
460
        $createdUrlAlias = $urlAliasService->createGlobalUrlAlias(
461
            'module:content/view/full/' . $locationId,
462
            '/Home/My-New-Site-global',
463
            'eng-US',
464
            false,
465
            true
466
        );
467
        /* END: Use Case */
468
469
        $this->assertInstanceOf(
470
            URLAlias::class,
471
            $createdUrlAlias
472
        );
473
474
        return [$createdUrlAlias, $location->id];
475
    }
476
477
    /**
478
     * Test for the createUrlAlias() method.
@@ 482-510 (lines=29) @@
479
     *
480
     * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable)
481
     */
482
    public function testCreateGlobalUrlAliasForLocationVariation()
483
    {
484
        $repository = $this->getRepository();
485
486
        $locationId = $this->generateId('location', 5);
487
        $locationService = $repository->getLocationService();
488
        $location = $locationService->loadLocation($locationId);
489
490
        /* BEGIN: Use Case */
491
        // $locationId is the ID of an existing location
492
493
        $urlAliasService = $repository->getURLAliasService();
494
495
        $createdUrlAlias = $urlAliasService->createGlobalUrlAlias(
496
            'eznode:' . $locationId,
497
            '/Home/My-New-Site-global',
498
            'eng-US',
499
            false,
500
            true
501
        );
502
        /* END: Use Case */
503
504
        $this->assertInstanceOf(
505
            URLAlias::class,
506
            $createdUrlAlias
507
        );
508
509
        return [$createdUrlAlias, $location->id];
510
    }
511
512
    /**
513
     * @param \eZ\Publish\API\Repository\Values\Content\URLAlias