[FOLLOWUP][TASK] Enhance DataHandler translation and synchronization handling
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / Regular / Modify / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Modify;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Functional test for the DataHandler
19 */
20 class ActionTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\AbstractActionTestCase
21 {
22 /**
23 * @var string
24 */
25 protected $assertionDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Regular/Modify/DataSet/';
26
27 /**
28 * Content records
29 */
30
31 /**
32 * @test
33 * @see DataSet/createContentRecords.csv
34 */
35 public function createContents()
36 {
37 parent::createContents();
38 $this->assertAssertionDataSet('createContents');
39
40 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
41 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
42 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1', 'Testing #2'));
43 }
44
45 /**
46 * @test
47 * @see DataSet/createContentForLanguageAll.csv
48 */
49 public function createContentForLanguageAll()
50 {
51 parent::createContentForLanguageAll();
52
53 $this->assertAssertionDataSet('createContentForLanguageAll');
54
55 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageIdSecond)->getResponseSections();
56 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
57 ->setTable(self::TABLE_Content)->setField('header')->setValues('Language set to all'));
58 }
59
60 /**
61 * @test
62 * @see DataSet/modifyContentRecord.csv
63 */
64 public function modifyContent()
65 {
66 parent::modifyContent();
67 $this->assertAssertionDataSet('modifyContent');
68
69 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
70 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
71 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
72 }
73
74 /**
75 * @test
76 * @see DataSet/deleteContentRecord.csv
77 */
78 public function deleteContent()
79 {
80 parent::deleteContent();
81 $this->assertAssertionDataSet('deleteContent');
82
83 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
84 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
85 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
86 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
87 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
88 }
89
90 /**
91 * @test
92 * @see DataSet/deleteLocalizedContentNDeleteContent.csv
93 */
94 public function deleteLocalizedContentAndDeleteContent()
95 {
96 parent::deleteLocalizedContentAndDeleteContent();
97 $this->assertAssertionDataSet('deleteLocalizedContentNDeleteContent');
98
99 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
100 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
101 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #3', '[Translate to Dansk:] Regular Element #3'));
102 }
103
104 /**
105 * @test
106 * @see DataSet/copyContentRecord.csv
107 */
108 public function copyContent()
109 {
110 parent::copyContent();
111 $this->assertAssertionDataSet('copyContent');
112
113 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
114 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
115 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
116 }
117
118 /**
119 * @test
120 * @see DataSet/copyContentToLanguage.csv
121 */
122 public function copyContentToLanguage()
123 {
124 parent::copyContentToLanguage();
125 $this->assertAssertionDataSet('copyContentToLanguage');
126
127 $this->setUpFrontendRootPage(1, [
128 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
129 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRendererNoOverlay.ts'
130 ]);
131 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
132 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
133 ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #3', '[Translate to Dansk:] Regular Element #2'));
134 }
135
136 /**
137 * @test
138 * @see DataSet/copyContentToLanguageFromNonDefaultLanguage.csv
139 */
140 public function copyContentToLanguageFromNonDefaultLanguage()
141 {
142 parent::copyContentToLanguageFromNonDefaultLanguage();
143 $this->assertAssertionDataSet('copyContentToLanguageFromNonDefaultLanguage');
144
145 $this->setUpFrontendRootPage(1, [
146 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
147 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRendererNoOverlay.ts'
148 ]);
149 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageIdSecond)->getResponseSections();
150 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
151 ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Deutsch:] [Translate to Dansk:] Regular Element #3'));
152 }
153
154 /**
155 * @test
156 * @see DataSet/copyContentRecord.csv
157 */
158 public function copyPasteContent()
159 {
160 parent::copyPasteContent();
161 $this->assertAssertionDataSet('copyPasteContent');
162
163 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
164 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
165 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
166 }
167
168 /**
169 * @test
170 * @see DataSet/localizeContentRecord.csv
171 */
172 public function localizeContent()
173 {
174 parent::localizeContent();
175 $this->assertAssertionDataSet('localizeContent');
176
177 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
178 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
179 ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
180 }
181
182 /**
183 * @test
184 * @see DataSet/localizeContentWSynchronization.csv
185 */
186 public function localizeContentWithLanguageSynchronization()
187 {
188 parent::localizeContentWithLanguageSynchronization();
189 $this->assertAssertionDataSet('localizeContentWSynchronization');
190
191 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
192 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
193 ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #1', 'Testing #1'));
194 }
195
196 /**
197 * @test
198 * @see DataSet/localizeContentFromNonDefaultLanguage.csv
199 */
200 public function localizeContentFromNonDefaultLanguage()
201 {
202 parent::localizeContentFromNonDefaultLanguage();
203
204 $this->assertAssertionDataSet('localizeContentFromNonDefaultLanguage');
205
206 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageIdSecond)->getResponseSections();
207 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
208 ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1', '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #3'));
209 }
210
211 /**
212 * @test
213 * @see DataSet/localizeContentFromNonDefaultLanguageWSynchronizationDefault.csv
214 */
215 public function localizeContentFromNonDefaultLanguageWithLanguageSynchronizationDefault()
216 {
217 parent::localizeContentFromNonDefaultLanguageWithLanguageSynchronizationDefault();
218
219 $this->assertAssertionDataSet('localizeContentFromNonDefaultLanguageWSynchronizationDefault');
220
221 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageIdSecond)->getResponseSections();
222 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
223 ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1', 'Testing #1'));
224 }
225
226 /**
227 * @test
228 * @see DataSet/changeContentRecordSorting.csv
229 */
230 public function changeContentSorting()
231 {
232 parent::changeContentSorting();
233 $this->assertAssertionDataSet('changeContentSorting');
234
235 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
236 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
237 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
238 }
239
240 /**
241 * @test
242 * @see DataSet/moveContentRecordToDifferentPage.csv
243 */
244 public function moveContentToDifferentPage()
245 {
246 parent::moveContentToDifferentPage();
247 $this->assertAssertionDataSet('moveContentToDifferentPage');
248
249 $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
250 $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
251 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
252 $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
253 $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
254 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
255 }
256
257 /**
258 * @test
259 * @see DataSet/movePasteContentToDifferentPage.csv
260 */
261 public function movePasteContentToDifferentPage()
262 {
263 parent::movePasteContentToDifferentPage();
264 $this->assertAssertionDataSet('movePasteContentToDifferentPage');
265
266 $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
267 $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
268 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
269 $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
270 $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
271 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
272 }
273
274 /**
275 * @test
276 * @see DataSet/moveContentRecordToDifferentPageAndChangeSorting.csv
277 */
278 public function moveContentToDifferentPageAndChangeSorting()
279 {
280 parent::moveContentToDifferentPageAndChangeSorting();
281 $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
282
283 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
284 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
285 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
286 }
287
288 /**
289 * Page records
290 */
291
292 /**
293 * @test
294 * @see DataSet/createPageRecord.csv
295 */
296 public function createPage()
297 {
298 parent::createPage();
299 $this->assertAssertionDataSet('createPage');
300
301 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'])->getResponseSections();
302 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
303 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
304 }
305
306 /**
307 * @test
308 * @see DataSet/modifyPageRecord.csv
309 */
310 public function modifyPage()
311 {
312 parent::modifyPage();
313 $this->assertAssertionDataSet('modifyPage');
314
315 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
316 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
317 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
318 }
319
320 /**
321 * @test
322 * @see DataSet/deletePageRecord.csv
323 */
324 public function deletePage()
325 {
326 parent::deletePage();
327 $this->assertAssertionDataSet('deletePage');
328
329 $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, false);
330 $this->assertContains('PageNotFoundException', $response->getError());
331 }
332
333 /**
334 * @test
335 * @see DataSet/copyPage.csv
336 */
337 public function copyPage()
338 {
339 parent::copyPage();
340 $this->assertAssertionDataSet('copyPage');
341
342 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'])->getResponseSections();
343 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
344 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
345 }
346
347 /**
348 * Copy page (id 90) containing content elements translated in "free mode".
349 * Values in l10n_source field are remapped to ids of newly copied records
350 * e.g. record 314 has l10n_source = 315 and record 313 has l10n_source = 314
351 * also note that 314 is NOT a record in the default language
352 *
353 * @test
354 * @see DataSet/copyPageFreeMode.csv
355 */
356 public function copyPageFreeMode()
357 {
358 $this->importScenarioDataSet('LivePageFreeModeElements');
359 parent::copyPageFreeMode();
360 $this->assertAssertionDataSet('copyPageFreeMode');
361
362 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'])->getResponseSections();
363 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
364 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target'));
365 }
366
367 /**
368 * @test
369 * @see DataSet/localizePageRecord.csv
370 */
371 public function localizePage()
372 {
373 parent::localizePage();
374 $this->assertAssertionDataSet('localizePage');
375
376 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
377 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
378 ->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
379 }
380
381 /**
382 * @test
383 * @see DataSet/localizeNCopyPage.csv
384 */
385 public function localizeAndCopyPage()
386 {
387 parent::localizePage();
388 parent::copyPage();
389 $this->assertAssertionDataSet('localizeNCopyPage');
390
391 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], self::VALUE_LanguageId)->getResponseSections();
392 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
393 ->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
394 }
395
396 /**
397 * @test
398 * @see DataSet/localizePageWSynchronization.csv
399 */
400 public function localizePageWithLanguageSynchronization()
401 {
402 parent::localizePageWithLanguageSynchronization();
403 $this->assertAssertionDataSet('localizePageWSynchronization');
404
405 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
406 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
407 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
408 }
409
410 /**
411 * @test
412 * @see DataSet/localizeNCopyPageWSynchronization.csv
413 */
414 public function localizeAndCopyPageWithLanguageSynchronization()
415 {
416 parent::localizePageWithLanguageSynchronization();
417 parent::copyPage();
418 $this->assertAssertionDataSet('localizeNCopyPageWSynchronization');
419
420 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
421 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
422 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
423 }
424
425 /**
426 * @test
427 * @see DataSet/changePageRecordSorting.csv
428 */
429 public function changePageSorting()
430 {
431 parent::changePageSorting();
432 $this->assertAssertionDataSet('changePageSorting');
433
434 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
435 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
436 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
437 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
438 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
439 }
440
441 /**
442 * @test
443 * @see DataSet/movePageRecordToDifferentPage.csv
444 */
445 public function movePageToDifferentPage()
446 {
447 parent::movePageToDifferentPage();
448 $this->assertAssertionDataSet('movePageToDifferentPage');
449
450 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
451 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
452 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
453 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
454 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
455 }
456
457 /**
458 * @test
459 * @see DataSet/movePageRecordToDifferentPageAndChangeSorting.csv
460 */
461 public function movePageToDifferentPageAndChangeSorting()
462 {
463 parent::movePageToDifferentPageAndChangeSorting();
464 $this->assertAssertionDataSet('movePageToDifferentPageNChangeSorting');
465
466 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
467 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
468 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
469 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
470 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
471 }
472 }