Completed
Push — 7.5 ( 670678...55f04b )
by
unknown
19:38
created

CustomUrlAliasForMultilingualContentTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCreateCustomUrlAliasWithTheSamePathThrowsException() 0 34 1
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Publish\API\Repository\Tests\URLAliasService;
10
11
use eZ\Publish\API\Repository\Exceptions\InvalidArgumentException;
12
use eZ\Publish\API\Repository\Tests\BaseTest;
13
14
final class CustomUrlAliasForMultilingualContentTest extends BaseTest
15
{
16
    /**
17
     * @covers \eZ\Publish\API\Repository\ContentService::publishVersion
18
     * @covers \eZ\Publish\API\Repository\URLAliasService::createUrlAlias
19
     *
20
     * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException
21
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
22
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
23
     */
24
    public function testCreateCustomUrlAliasWithTheSamePathThrowsException(): void
25
    {
26
        $repository = $this->getRepository();
27
        $urlAliasService = $repository->getURLAliasService();
28
        $locationService = $repository->getLocationService();
29
        $language = 'ger-DE';
30
31
        $names = [
32
            'eng-GB' => 'Contact',
33
            'ger-DE' => 'Kontakt',
34
            'eng-US' => 'Contact',
35
        ];
36
        $contactFolder = $this->createFolder(
37
            $names,
38
            2,
39
            false // not always available, so the created content behaves the same as "article"
40
        );
41
42
        $this->expectException(InvalidArgumentException::class);
43
        $this->expectExceptionMessage(
44
            'Argument \'$path\' is invalid: Path \'Contact\' already exists for the given context'
45
        );
46
        // attempt to create custom alias for German translation while a system one
47
        // for a different translation already exists
48
        $urlAliasService->createUrlAlias(
49
            $locationService->loadLocation(
50
                $contactFolder->contentInfo->mainLocationId
51
            ),
52
            'Contact',
53
            $language,
54
            true, // forwarding
55
            true // always available
56
        );
57
    }
58
}
59