Code Duplication    Length = 24-29 lines in 4 locations

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

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