Completed
Push — 7.5 ( 13f815...467086 )
by André
19:24
created

ContentServiceTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B testPublishMultipleVersions() 0 39 6
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\Parallel;
10
11
use eZ\Publish\Core\Base\Exceptions\BadStateException;
12
13
final class ContentServiceTest extends BaseParallelTestCase
14
{
15
    public function testPublishMultipleVersions(): void
16
    {
17
        $repository = $this->getRepository();
18
19
        $contentService = $repository->getContentService();
20
        $content = $this->createFolder(
21
            [
22
                'eng-US' => 'Content',
23
            ],
24
            $this->generateId('location', 2)
25
        );
26
27
        $version1 = $contentService->createContentDraft($content->contentInfo, $content->versionInfo);
28
        $version2 = $contentService->createContentDraft($content->contentInfo, $content->versionInfo);
29
30
        $processList = new ParallelProcessList();
31
        $this->addParallelProcess($processList, function () use ($version1 , $contentService) {
32
            try {
33
                $contentService->publishVersion($version1->versionInfo);
34
            } catch (BadStateException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
35
            }
36
        });
37
38
        $this->addParallelProcess($processList, function () use ($version2 , $contentService) {
39
            try {
40
                $contentService->publishVersion($version2->versionInfo);
41
            } catch (BadStateException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
42
            }
43
        });
44
45
        $this->runParallelProcesses($processList);
46
47
        $version1 = $contentService->loadVersionInfo($version1->contentInfo, 2);
48
        $version2 = $contentService->loadVersionInfo($version2->contentInfo, 3);
49
50
        $this->assertTrue(
51
            $version1->isPublished() && $version2->isDraft() || $version1->isDraft() && $version2->isPublished(),
52
            'One of the versions should be published and the other should be draft');
53
    }
54
}
55