Skip to content

Commit ceb8c7a

Browse files
committed
IBX-6494: CS
1 parent a257944 commit ceb8c7a

File tree

1 file changed

+24
-41
lines changed

1 file changed

+24
-41
lines changed

tests/integration/Core/Repository/ContentService/CopyNonTranslatableFieldsFromPublishedVersionTest.php

+24-41
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Ibexa\Tests\Integration\Core\Repository\ContentService;
1010

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

3334
$contentService = self::getContentService();
34-
$contentTypeService = self::getContentTypeService();
35-
$locationService = self::getLocationService();
3635

3736
// Creating start content in eng-US language
38-
$contentType = $contentTypeService->loadContentTypeByIdentifier(self::CONTENT_TYPE_IDENTIFIER);
39-
$mainLanguageCode = self::ENG_US;
40-
$contentCreateStruct = $contentService->newContentCreateStruct($contentType, $mainLanguageCode);
41-
$contentCreateStruct->setField('title', 'Test title');
42-
43-
$contentDraft = $contentService->createContent(
44-
$contentCreateStruct,
45-
[
46-
$locationService->newLocationCreateStruct(2),
47-
]
48-
);
37+
$contentDraft = $this->createEngDraft();
4938
$publishedContent = $contentService->publishVersion($contentDraft->getVersionInfo());
5039

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

9483
$contentService = self::getContentService();
95-
$contentTypeService = self::getContentTypeService();
96-
$locationService = self::getLocationService();
9784

9885
// Creating start content in eng-US language
99-
$contentType = $contentTypeService->loadContentTypeByIdentifier(self::CONTENT_TYPE_IDENTIFIER);
100-
$mainLanguageCode = self::ENG_US;
101-
$contentCreateStruct = $contentService->newContentCreateStruct($contentType, $mainLanguageCode);
102-
$contentCreateStruct->setField('title', 'Test title');
103-
$contentCreateStruct->setField('body', 'Nontranslatable body');
104-
105-
$contentDraft = $contentService->createContent(
106-
$contentCreateStruct,
107-
[
108-
$locationService->newLocationCreateStruct(2),
109-
]
110-
);
86+
$contentDraft = $this->createEngDraft();
11187
$publishedContent = $contentService->publishVersion($contentDraft->getVersionInfo());
11288

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

150126
$contentService = self::getContentService();
151-
$contentTypeService = self::getContentTypeService();
152-
$locationService = self::getLocationService();
153127

154128
// Creating start content in eng-US language
155-
$contentType = $contentTypeService->loadContentTypeByIdentifier(self::CONTENT_TYPE_IDENTIFIER);
156-
$mainLanguageCode = self::ENG_US;
157-
$contentCreateStruct = $contentService->newContentCreateStruct($contentType, $mainLanguageCode);
158-
$contentCreateStruct->setField('title', 'Test title');
159-
$contentCreateStruct->setField('body', 'Test body');
160-
161-
$contentDraft = $contentService->createContent(
162-
$contentCreateStruct,
163-
[
164-
$locationService->newLocationCreateStruct(2),
165-
]
166-
);
129+
$contentDraft = $this->createEngDraft();
167130
$publishedContent = $contentService->publishVersion($contentDraft->getVersionInfo());
168131

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

166+
private function createEngDraft(): Content
167+
{
168+
$contentService = self::getContentService();
169+
$contentTypeService = self::getContentTypeService();
170+
$locationService = self::getLocationService();
171+
172+
$contentType = $contentTypeService->loadContentTypeByIdentifier(self::CONTENT_TYPE_IDENTIFIER);
173+
$mainLanguageCode = self::ENG_US;
174+
$contentCreateStruct = $contentService->newContentCreateStruct($contentType, $mainLanguageCode);
175+
$contentCreateStruct->setField('title', 'Test title');
176+
$contentCreateStruct->setField('body', 'Test body');
177+
178+
return $contentService->createContent(
179+
$contentCreateStruct,
180+
[
181+
$locationService->newLocationCreateStruct(2),
182+
]
183+
);
184+
}
185+
203186
private function createNonTranslatableContentType(): void
204187
{
205188
$permissionResolver = self::getPermissionResolver();

0 commit comments

Comments
 (0)