Skip to content

Commit

Permalink
simplify integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed May 30, 2019
1 parent a0fab8c commit 49811ac
Showing 1 changed file with 13 additions and 42 deletions.
55 changes: 13 additions & 42 deletions eZ/Publish/API/Repository/Tests/ContentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6654,66 +6654,37 @@ function (Location $location) {
);
}

public function testCopyTranslationsWithSelectedLanguages()
public function testPublishVersionWithSelectedLanguages()
{
$repository = $this->getRepository();

$contentService = $repository->getContentService();

$contentDraft = $this->createContentDraft(
'folder',
$this->generateId('location', 2),
$publishedContent = $this->createFolder(
[
'name' => 'Published US',
]
'eng-US' => 'Published US',
'ger-DE' => 'Published DE',
],
$this->generateId('location', 2)
);

$publishedContent = $contentService->publishVersion($contentDraft->versionInfo);

$usDraft1 = $contentService->createContentDraft($publishedContent->contentInfo);
$draft = $contentService->createContentDraft($publishedContent->contentInfo);
$contentUpdateStruct = new ContentUpdateStruct([
'initialLanguageCode' => 'eng-US',
'fields' => $contentDraft->getFields(),
]);
$contentUpdateStruct->setField('name', 'Draft 1 US', 'eng-US');
$contentService->updateContent($usDraft1->versionInfo, $contentUpdateStruct);


$deDraft = $contentService->createContentDraft($publishedContent->contentInfo);
$contentUpdateStruct = new ContentUpdateStruct([
'initialLanguageCode' => 'ger-DE',
'fields' => $contentDraft->getFields(),
]);
$contentUpdateStruct->setField('name', 'Published GER', 'ger-DE');
$gerContent = $contentService->updateContent($deDraft->versionInfo, $contentUpdateStruct);
$contentService->publishVersion($gerContent->versionInfo);

$publishedContent = $contentService->publishVersion($usDraft1->versionInfo);

$usDraft2 = $contentService->createContentDraft($publishedContent->contentInfo);
$contentUpdateStruct = new ContentUpdateStruct([
'initialLanguageCode' => 'eng-US',
'fields' => $contentDraft->getFields(),
]);
$contentUpdateStruct->setField('name', 'Draft 2 US', 'eng-US');
$contentService->updateContent($usDraft2->versionInfo, $contentUpdateStruct);

$deDraft1 = $contentService->createContentDraft($publishedContent->contentInfo);
$contentUpdateStruct = new ContentUpdateStruct([
'initialLanguageCode' => 'ger-DE',
'fields' => $contentDraft->getFields(),
]);
$contentUpdateStruct->setField('name', 'Draft 1 DE', 'ger-DE');
$contentService->updateContent($deDraft1->versionInfo, $contentUpdateStruct);

$contentService->publishVersion($usDraft2->versionInfo);
$dePublished = $contentService->publishVersion($deDraft1->versionInfo, ['ger-DE']);
$contentService->updateContent($draft->versionInfo, $contentUpdateStruct);

$contentService->publishVersion($draft->versionInfo, ['ger-DE']);
$content = $contentService->loadContent($draft->contentInfo->id);
$this->assertEquals(
[
'eng-US' => 'Draft 2 US',
'eng-US' => 'Published US',
'ger-DE' => 'Draft 1 DE',
],
$dePublished->fields['name']
$content->fields['name']
);
}
}

0 comments on commit 49811ac

Please sign in to comment.