@@ -87,7 +87,7 @@ public function testCopyNonTranslatableFieldsFromPublishedVersionToDraft(): void
87
87
/**
88
88
* @throws \eZ\Publish\API\Repository\Exceptions\Exception
89
89
*/
90
- public function testCopyNonTranslatableFieldsFromPublishedVersionToLatestVersion (): void
90
+ public function testCopyNonTranslatableFieldsTwoParallelDrafts (): void
91
91
{
92
92
$ this ->createNonTranslatableContentType ();
93
93
@@ -140,6 +140,66 @@ public function testCopyNonTranslatableFieldsFromPublishedVersionToLatestVersion
140
140
self ::assertSame ('Nontranslatable body v2 ' , $ bodyFieldValue ->text );
141
141
}
142
142
143
+ /**
144
+ * @throws \eZ\Publish\API\Repository\Exceptions\Exception
145
+ */
146
+ public function testCopyNonTranslatableFieldsOverridesNonMainLanguageDrafts (): void
147
+ {
148
+ $ this ->createNonTranslatableContentType ();
149
+
150
+ $ contentService = self ::getContentService ();
151
+ $ contentTypeService = self ::getContentTypeService ();
152
+ $ locationService = self ::getLocationService ();
153
+
154
+ // 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
+ );
167
+ $ publishedContent = $ contentService ->publishVersion ($ contentDraft ->getVersionInfo ());
168
+
169
+ // Creating a draft in ger-DE language with the only field updated being 'title'
170
+ $ gerDraft = $ contentService ->createContentDraft ($ publishedContent ->contentInfo );
171
+
172
+ $ contentUpdateStruct = new ContentUpdateStruct ([
173
+ 'initialLanguageCode ' => self ::GER_DE ,
174
+ 'fields ' => $ contentDraft ->getFields (),
175
+ ]);
176
+
177
+ $ contentUpdateStruct ->setField ('title ' , 'Folder GER ' , self ::GER_DE );
178
+ $ gerContent = $ contentService ->updateContent ($ gerDraft ->getVersionInfo (), $ contentUpdateStruct );
179
+ $ publishedContent = $ contentService ->publishVersion ($ gerContent ->getVersionInfo ());
180
+
181
+ // Updating non-translatable field in eng-US language (allowed) and publishing it
182
+ $ engContent = $ contentService ->createContentDraft ($ publishedContent ->contentInfo );
183
+
184
+ $ contentUpdateStruct = new ContentUpdateStruct ([
185
+ 'initialLanguageCode ' => self ::ENG_US ,
186
+ 'fields ' => $ contentDraft ->getFields (),
187
+ ]);
188
+
189
+ $ expectedBodyValue = 'Non-translatable value ' ;
190
+ $ contentUpdateStruct ->setField ('title ' , 'Title v2 ' , self ::ENG_US );
191
+ $ contentUpdateStruct ->setField ('body ' , $ expectedBodyValue , self ::ENG_US );
192
+
193
+ $ engContent = $ contentService ->updateContent ($ engContent ->getVersionInfo (), $ contentUpdateStruct );
194
+ $ contentService ->publishVersion ($ engContent ->getVersionInfo ());
195
+
196
+ // Loading content in ger-DE language
197
+ $ mainPublishedContent = $ contentService ->loadContent ($ engContent ->id , ['ger-DE ' ]);
198
+ $ bodyFieldValue = $ mainPublishedContent ->getField ('body ' )->getValue ();
199
+
200
+ self ::assertSame ($ expectedBodyValue , $ bodyFieldValue ->text );
201
+ }
202
+
143
203
private function createNonTranslatableContentType (): void
144
204
{
145
205
$ permissionResolver = self ::getPermissionResolver ();
0 commit comments