Code Duplication    Length = 24-29 lines in 4 locations

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

@@ 121-144 (lines=24) @@
118
     * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias($location, $path, $languageCode, $forwarding)
119
     * @depends testCreateUrlAliasPropertyValues
120
     */
121
    public function testCreateUrlAliasWithForwarding()
122
    {
123
        $repository = $this->getRepository();
124
125
        $locationId = $this->generateId('location', 5);
126
127
        /* BEGIN: Use Case */
128
        // $locationId is the ID of an existing location
129
130
        $locationService = $repository->getLocationService();
131
        $urlAliasService = $repository->getURLAliasService();
132
133
        $location = $locationService->loadLocation($locationId);
134
135
        $createdUrlAlias = $urlAliasService->createUrlAlias($location, '/Home/My-New-Site', 'eng-US', true);
136
        /* END: Use Case */
137
138
        $this->assertInstanceOf(
139
            'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias',
140
            $createdUrlAlias
141
        );
142
143
        return array($createdUrlAlias, $location->id);
144
    }
145
146
    /**
147
     * @param array $testData
@@ 177-200 (lines=24) @@
174
     *
175
     * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias($location, $path, $languageCode, $forwarding, $alwaysAvailable)
176
     */
177
    public function testCreateUrlAliasWithAlwaysAvailable()
178
    {
179
        $repository = $this->getRepository();
180
181
        $locationId = $this->generateId('location', 5);
182
183
        /* BEGIN: Use Case */
184
        // $locationId is the ID of an existing location
185
186
        $locationService = $repository->getLocationService();
187
        $urlAliasService = $repository->getURLAliasService();
188
189
        $location = $locationService->loadLocation($locationId);
190
191
        $createdUrlAlias = $urlAliasService->createUrlAlias($location, '/Home/My-New-Site', 'eng-US', false, true);
192
        /* END: Use Case */
193
194
        $this->assertInstanceOf(
195
            'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias',
196
            $createdUrlAlias
197
        );
198
199
        return array($createdUrlAlias, $location->id);
200
    }
201
202
    /**
203
     * @param array $testData
@@ 415-443 (lines=29) @@
412
     *
413
     * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable)
414
     */
415
    public function testCreateGlobalUrlAliasForLocation()
416
    {
417
        $repository = $this->getRepository();
418
419
        $locationId = $this->generateId('location', 5);
420
        $locationService = $repository->getLocationService();
421
        $location = $locationService->loadLocation($locationId);
422
423
        /* BEGIN: Use Case */
424
        // $locationId is the ID of an existing location
425
426
        $urlAliasService = $repository->getURLAliasService();
427
428
        $createdUrlAlias = $urlAliasService->createGlobalUrlAlias(
429
            'module:content/view/full/' . $locationId,
430
            '/Home/My-New-Site-global',
431
            'eng-US',
432
            false,
433
            true
434
        );
435
        /* END: Use Case */
436
437
        $this->assertInstanceOf(
438
            'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias',
439
            $createdUrlAlias
440
        );
441
442
        return array($createdUrlAlias, $location->id);
443
    }
444
445
    /**
446
     * Test for the createUrlAlias() method.
@@ 450-478 (lines=29) @@
447
     *
448
     * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable)
449
     */
450
    public function testCreateGlobalUrlAliasForLocationVariation()
451
    {
452
        $repository = $this->getRepository();
453
454
        $locationId = $this->generateId('location', 5);
455
        $locationService = $repository->getLocationService();
456
        $location = $locationService->loadLocation($locationId);
457
458
        /* BEGIN: Use Case */
459
        // $locationId is the ID of an existing location
460
461
        $urlAliasService = $repository->getURLAliasService();
462
463
        $createdUrlAlias = $urlAliasService->createGlobalUrlAlias(
464
            'eznode:' . $locationId,
465
            '/Home/My-New-Site-global',
466
            'eng-US',
467
            false,
468
            true
469
        );
470
        /* END: Use Case */
471
472
        $this->assertInstanceOf(
473
            'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias',
474
            $createdUrlAlias
475
        );
476
477
        return array($createdUrlAlias, $location->id);
478
    }
479
480
    /**
481
     * @param \eZ\Publish\API\Repository\Values\Content\URLAlias