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) { |
|
|
|
|
35
|
|
|
} |
36
|
|
|
}); |
37
|
|
|
|
38
|
|
|
$this->addParallelProcess($processList, function () use ($version2 , $contentService) { |
39
|
|
|
try { |
40
|
|
|
$contentService->publishVersion($version2->versionInfo); |
41
|
|
|
} catch (BadStateException $e) { |
|
|
|
|
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
|
|
|
|