Code Duplication    Length = 24-29 lines in 4 locations

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

@@ 129-152 (lines=24) @@
126
     * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias($location, $path, $languageCode, $forwarding)
127
     * @depends testCreateUrlAliasPropertyValues
128
     */
129
    public function testCreateUrlAliasWithForwarding()
130
    {
131
        $repository = $this->getRepository();
132
133
        $locationId = $this->generateId('location', 5);
134
135
        /* BEGIN: Use Case */
136
        // $locationId is the ID of an existing location
137
138
        $locationService = $repository->getLocationService();
139
        $urlAliasService = $repository->getURLAliasService();
140
141
        $location = $locationService->loadLocation($locationId);
142
143
        $createdUrlAlias = $urlAliasService->createUrlAlias($location, '/Home/My-New-Site', 'eng-US', true);
144
        /* END: Use Case */
145
146
        $this->assertInstanceOf(
147
            'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias',
148
            $createdUrlAlias
149
        );
150
151
        return [$createdUrlAlias, $location->id];
152
    }
153
154
    /**
155
     * @param array $testData
@@ 185-208 (lines=24) @@
182
     *
183
     * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias($location, $path, $languageCode, $forwarding, $alwaysAvailable)
184
     */
185
    public function testCreateUrlAliasWithAlwaysAvailable()
186
    {
187
        $repository = $this->getRepository();
188
189
        $locationId = $this->generateId('location', 5);
190
191
        /* BEGIN: Use Case */
192
        // $locationId is the ID of an existing location
193
194
        $locationService = $repository->getLocationService();
195
        $urlAliasService = $repository->getURLAliasService();
196
197
        $location = $locationService->loadLocation($locationId);
198
199
        $createdUrlAlias = $urlAliasService->createUrlAlias($location, '/Home/My-New-Site', 'eng-US', false, true);
200
        /* END: Use Case */
201
202
        $this->assertInstanceOf(
203
            'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias',
204
            $createdUrlAlias
205
        );
206
207
        return [$createdUrlAlias, $location->id];
208
    }
209
210
    /**
211
     * @param array $testData
@@ 424-452 (lines=29) @@
421
     *
422
     * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable)
423
     */
424
    public function testCreateGlobalUrlAliasForLocation()
425
    {
426
        $repository = $this->getRepository();
427
428
        $locationId = $this->generateId('location', 5);
429
        $locationService = $repository->getLocationService();
430
        $location = $locationService->loadLocation($locationId);
431
432
        /* BEGIN: Use Case */
433
        // $locationId is the ID of an existing location
434
435
        $urlAliasService = $repository->getURLAliasService();
436
437
        $createdUrlAlias = $urlAliasService->createGlobalUrlAlias(
438
            'module:content/view/full/' . $locationId,
439
            '/Home/My-New-Site-global',
440
            'eng-US',
441
            false,
442
            true
443
        );
444
        /* END: Use Case */
445
446
        $this->assertInstanceOf(
447
            'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias',
448
            $createdUrlAlias
449
        );
450
451
        return [$createdUrlAlias, $location->id];
452
    }
453
454
    /**
455
     * Test for the createUrlAlias() method.
@@ 459-487 (lines=29) @@
456
     *
457
     * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable)
458
     */
459
    public function testCreateGlobalUrlAliasForLocationVariation()
460
    {
461
        $repository = $this->getRepository();
462
463
        $locationId = $this->generateId('location', 5);
464
        $locationService = $repository->getLocationService();
465
        $location = $locationService->loadLocation($locationId);
466
467
        /* BEGIN: Use Case */
468
        // $locationId is the ID of an existing location
469
470
        $urlAliasService = $repository->getURLAliasService();
471
472
        $createdUrlAlias = $urlAliasService->createGlobalUrlAlias(
473
            'eznode:' . $locationId,
474
            '/Home/My-New-Site-global',
475
            'eng-US',
476
            false,
477
            true
478
        );
479
        /* END: Use Case */
480
481
        $this->assertInstanceOf(
482
            'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias',
483
            $createdUrlAlias
484
        );
485
486
        return [$createdUrlAlias, $location->id];
487
    }
488
489
    /**
490
     * @param \eZ\Publish\API\Repository\Values\Content\URLAlias