9
9
namespace Ibexa \Tests \Integration \Core \Repository \ContentService ;
10
10
11
11
use DateTime ;
12
+ use eZ \Publish \API \Repository \Values \Content \Content ;
12
13
use eZ \Publish \API \Repository \Values \ContentType \FieldDefinitionCreateStruct ;
13
14
use eZ \Publish \Core \Repository \Values \Content \ContentUpdateStruct ;
14
15
use Ibexa \Tests \Integration \Core \RepositoryTestCase ;
@@ -31,21 +32,9 @@ public function testCopyNonTranslatableFieldsFromPublishedVersionToDraft(): void
31
32
$ this ->createNonTranslatableContentType ();
32
33
33
34
$ contentService = self ::getContentService ();
34
- $ contentTypeService = self ::getContentTypeService ();
35
- $ locationService = self ::getLocationService ();
36
35
37
36
// 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 ();
49
38
$ publishedContent = $ contentService ->publishVersion ($ contentDraft ->getVersionInfo ());
50
39
51
40
// Creating a draft in ger-DE language with the only field updated being 'title'
@@ -92,22 +81,9 @@ public function testCopyNonTranslatableFieldsTwoParallelDrafts(): void
92
81
$ this ->createNonTranslatableContentType ();
93
82
94
83
$ contentService = self ::getContentService ();
95
- $ contentTypeService = self ::getContentTypeService ();
96
- $ locationService = self ::getLocationService ();
97
84
98
85
// 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 ();
111
87
$ publishedContent = $ contentService ->publishVersion ($ contentDraft ->getVersionInfo ());
112
88
113
89
// Creating two drafts at the same time
@@ -148,22 +124,9 @@ public function testCopyNonTranslatableFieldsOverridesNonMainLanguageDrafts(): v
148
124
$ this ->createNonTranslatableContentType ();
149
125
150
126
$ contentService = self ::getContentService ();
151
- $ contentTypeService = self ::getContentTypeService ();
152
- $ locationService = self ::getLocationService ();
153
127
154
128
// 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 ();
167
130
$ publishedContent = $ contentService ->publishVersion ($ contentDraft ->getVersionInfo ());
168
131
169
132
// Creating a draft in ger-DE language with the only field updated being 'title'
@@ -200,6 +163,26 @@ public function testCopyNonTranslatableFieldsOverridesNonMainLanguageDrafts(): v
200
163
self ::assertSame ($ expectedBodyValue , $ bodyFieldValue ->text );
201
164
}
202
165
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
+
203
186
private function createNonTranslatableContentType (): void
204
187
{
205
188
$ permissionResolver = self ::getPermissionResolver ();
0 commit comments