Completed
Push — EZP-26342-validation-improvmen... ( 9c5a9c...57b308 )
by André
56:51 queued 36:58
created

EZP26327UrlAliasHistorizationTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 10

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 1
lcom 1
cbo 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testHistorization() 0 36 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
 * @version //autogentag//
8
 */
9
namespace eZ\Publish\API\Repository\Tests\Regression;
10
11
use eZ\Publish\API\Repository\Tests\BaseTest;
12
13
/**
14
 * @issue https://jira.ez.no/browse/EZP-26327
15
 * @group ezp26327
16
 */
17
class EZP26327UrlAliasHistorizationTest extends BaseTest
18
{
19
    public function testHistorization()
20
    {
21
        $contentService = $this->getRepository()->getContentService();
22
        $contentTypeService = $this->getRepository()->getContentTypeService();
23
        $locationService = $this->getRepository()->getLocationService();
24
        $urlAliasService = $this->getRepository()->getURLAliasService();
25
26
        $contentType = $contentTypeService->loadContentTypeByIdentifier('folder');
27
        $locationCreateStruct = $locationService->newLocationCreateStruct(2);
28
        $contentCreateStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB');
29
30
        $contentCreateStruct->setField('name', 'name-gb', 'eng-GB');
31
        $contentCreateStruct->setField('name', 'name-us', 'eng-US');
32
33
        $draft = $contentService->createContent(
34
            $contentCreateStruct,
35
            [$locationCreateStruct]
36
        );
37
        $content = $contentService->publishVersion($draft->versionInfo);
38
39
        // Warmup cache
40
        $urlAliasService->lookup('/name-gb');
41
        $urlAliasService->lookup('/name-us');
42
43
        $contentUpdateStruct = $contentService->newContentUpdateStruct();
44
        $contentUpdateStruct->setField('name', 'name-gb', 'eng-US');
45
        $draft = $contentService->createContentDraft($content->contentInfo);
46
        $draft = $contentService->updateContent($draft->versionInfo, $contentUpdateStruct);
47
        $contentService->publishVersion($draft->versionInfo);
48
49
        $activeAlias = $urlAliasService->lookup('/name-gb');
50
        $historyAlias = $urlAliasService->lookup('/name-us');
51
52
        $this->assertFalse($activeAlias->isHistory);
53
        $this->assertTrue($historyAlias->isHistory);
54
    }
55
}
56