Skip to content

Commit

Permalink
IBX-6494: CS
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed Apr 15, 2024
1 parent a257944 commit ceb8c7a
Showing 1 changed file with 24 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Ibexa\Tests\Integration\Core\Repository\ContentService;

use DateTime;
use eZ\Publish\API\Repository\Values\Content\Content;
use eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionCreateStruct;
use eZ\Publish\Core\Repository\Values\Content\ContentUpdateStruct;
use Ibexa\Tests\Integration\Core\RepositoryTestCase;
Expand All @@ -31,21 +32,9 @@ public function testCopyNonTranslatableFieldsFromPublishedVersionToDraft(): void
$this->createNonTranslatableContentType();

$contentService = self::getContentService();
$contentTypeService = self::getContentTypeService();
$locationService = self::getLocationService();

// Creating start content in eng-US language
$contentType = $contentTypeService->loadContentTypeByIdentifier(self::CONTENT_TYPE_IDENTIFIER);
$mainLanguageCode = self::ENG_US;
$contentCreateStruct = $contentService->newContentCreateStruct($contentType, $mainLanguageCode);
$contentCreateStruct->setField('title', 'Test title');

$contentDraft = $contentService->createContent(
$contentCreateStruct,
[
$locationService->newLocationCreateStruct(2),
]
);
$contentDraft = $this->createEngDraft();
$publishedContent = $contentService->publishVersion($contentDraft->getVersionInfo());

// Creating a draft in ger-DE language with the only field updated being 'title'
Expand Down Expand Up @@ -92,22 +81,9 @@ public function testCopyNonTranslatableFieldsTwoParallelDrafts(): void
$this->createNonTranslatableContentType();

$contentService = self::getContentService();
$contentTypeService = self::getContentTypeService();
$locationService = self::getLocationService();

// Creating start content in eng-US language
$contentType = $contentTypeService->loadContentTypeByIdentifier(self::CONTENT_TYPE_IDENTIFIER);
$mainLanguageCode = self::ENG_US;
$contentCreateStruct = $contentService->newContentCreateStruct($contentType, $mainLanguageCode);
$contentCreateStruct->setField('title', 'Test title');
$contentCreateStruct->setField('body', 'Nontranslatable body');

$contentDraft = $contentService->createContent(
$contentCreateStruct,
[
$locationService->newLocationCreateStruct(2),
]
);
$contentDraft = $this->createEngDraft();
$publishedContent = $contentService->publishVersion($contentDraft->getVersionInfo());

// Creating two drafts at the same time
Expand Down Expand Up @@ -148,22 +124,9 @@ public function testCopyNonTranslatableFieldsOverridesNonMainLanguageDrafts(): v
$this->createNonTranslatableContentType();

$contentService = self::getContentService();
$contentTypeService = self::getContentTypeService();
$locationService = self::getLocationService();

// Creating start content in eng-US language
$contentType = $contentTypeService->loadContentTypeByIdentifier(self::CONTENT_TYPE_IDENTIFIER);
$mainLanguageCode = self::ENG_US;
$contentCreateStruct = $contentService->newContentCreateStruct($contentType, $mainLanguageCode);
$contentCreateStruct->setField('title', 'Test title');
$contentCreateStruct->setField('body', 'Test body');

$contentDraft = $contentService->createContent(
$contentCreateStruct,
[
$locationService->newLocationCreateStruct(2),
]
);
$contentDraft = $this->createEngDraft();
$publishedContent = $contentService->publishVersion($contentDraft->getVersionInfo());

// Creating a draft in ger-DE language with the only field updated being 'title'
Expand Down Expand Up @@ -200,6 +163,26 @@ public function testCopyNonTranslatableFieldsOverridesNonMainLanguageDrafts(): v
self::assertSame($expectedBodyValue, $bodyFieldValue->text);
}

private function createEngDraft(): Content
{
$contentService = self::getContentService();
$contentTypeService = self::getContentTypeService();
$locationService = self::getLocationService();

$contentType = $contentTypeService->loadContentTypeByIdentifier(self::CONTENT_TYPE_IDENTIFIER);
$mainLanguageCode = self::ENG_US;
$contentCreateStruct = $contentService->newContentCreateStruct($contentType, $mainLanguageCode);
$contentCreateStruct->setField('title', 'Test title');
$contentCreateStruct->setField('body', 'Test body');

return $contentService->createContent(
$contentCreateStruct,
[
$locationService->newLocationCreateStruct(2),
]
);
}

private function createNonTranslatableContentType(): void
{
$permissionResolver = self::getPermissionResolver();
Expand Down

0 comments on commit ceb8c7a

Please sign in to comment.