[BUGFIX] Make checks in localize compatible with new Localization Wizard
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / Regular / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Regular;
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 abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
21 {
22 const VALUE_ParentPageId = 88;
23 const VALUE_PageId = 89;
24 const VALUE_PageIdTarget = 90;
25 const VALUE_PageIdWebsite = 1;
26 const VALUE_ContentIdZero = 296;
27 const VALUE_ContentIdFirst = 297;
28 const VALUE_ContentIdSecond = 298;
29 const VALUE_ContentIdThird = 299;
30 const VALUE_ContentIdThirdLocalized = 300;
31 const VALUE_LanguageId = 1;
32 const VALUE_LanguageIdSecond = 2;
33 const VALUE_WorkspaceId = 1;
34
35 const TABLE_Page = 'pages';
36 const TABLE_PageOverlay = 'pages_language_overlay';
37 const TABLE_Content = 'tt_content';
38
39 /**
40 * @var array
41 */
42 protected $coreExtensionsToLoad = [
43 'fluid',
44 'version',
45 'workspaces',
46 ];
47
48 /**
49 * @var string
50 */
51 protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/';
52
53 protected function setUp()
54 {
55 parent::setUp();
56 $this->importScenarioDataSet('LiveDefaultPages');
57 $this->importScenarioDataSet('LiveDefaultElements');
58 $this->importScenarioDataSet('ReferenceIndex');
59
60 $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts']);
61 $this->backendUser->workspace = self::VALUE_WorkspaceId;
62 }
63
64 /**
65 * Content records
66 */
67
68 /**
69 * @see DataSet/Assertion/createContentRecords.csv
70 */
71 public function createContents()
72 {
73 // Creating record at the beginning of the page
74 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
75 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][0];
76 // Creating record at the end of the page (after last one)
77 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, -self::VALUE_ContentIdSecond, ['header' => 'Testing #2']);
78 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][0];
79 }
80
81 /**
82 * @see DataSet/Assertion/createContentRecordAndDiscardCreatedContentRecord.csv
83 */
84 public function createContentAndDiscardCreatedContent()
85 {
86 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
87 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
88 $versionedNewContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['newContentId']);
89 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedNewContentId);
90 }
91
92 /**
93 * @see DataSet/Assertion/createAndCopyContentRecordAndDiscardCopiedContentRecord.csv
94 */
95 public function createAndCopyContentAndDiscardCopiedContent()
96 {
97 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
98 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
99 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
100 $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
101 $versionedCopiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['copiedContentId']);
102 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId);
103 }
104
105 /**
106 * @see DataSet/Assertion/modifyContentRecord.csv
107 */
108 public function modifyContent()
109 {
110 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, ['header' => 'Testing #1']);
111 }
112
113 /**
114 * @see DataSet/Assertion/deleteContentRecord.csv
115 */
116 public function deleteContent()
117 {
118 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
119 }
120
121 /**
122 * @see DataSet/deleteLocalizedContentNDeleteContent.csv
123 */
124 public function deleteLocalizedContentAndDeleteContent()
125 {
126 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized);
127 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdThird);
128 }
129
130 /**
131 * @see DataSet/Assertion/copyContentRecord.csv
132 */
133 public function copyContent()
134 {
135 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageId);
136 $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
137 }
138
139 /**
140 * @see DataSet/Assertion/localizeContentRecord.csv
141 */
142 public function localizeContent()
143 {
144 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_LanguageId);
145 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
146 }
147
148 /**
149 * @see DataSet/Assertion/localizeContentRecord.csv
150 */
151 public function localizeContentFromNonDefaultLanguage()
152 {
153 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized, self::VALUE_LanguageIdSecond);
154 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdThirdLocalized];
155 }
156
157 /**
158 * @see DataSet/Assertion/changeContentRecordSorting.csv
159 */
160 public function changeContentSorting()
161 {
162 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
163 }
164
165 /**
166 * @see DataSet/changeContentSortingNDeleteMovedRecord.csv
167 */
168 public function changeContentSortingAndDeleteMovedRecord()
169 {
170 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
171 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
172 }
173
174 /**
175 * @see DataSet/changeContentSortingNDeleteLiveRecord.csv
176 */
177 public function changeContentSortingAndDeleteLiveRecord()
178 {
179 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
180 // Switch to live workspace
181 $this->backendUser->workspace = 0;
182 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
183 // Switch back to draft workspace
184 $this->backendUser->workspace = static::VALUE_WorkspaceId;
185 }
186
187 /**
188 * @see DataSet/Assertion/moveContentRecordToDifferentPage.csv
189 */
190 public function moveContentToDifferentPage()
191 {
192 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
193 }
194
195 /**
196 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
197 */
198 public function moveContentToDifferentPageAndChangeSorting()
199 {
200 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
201 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
202 }
203
204 /**
205 * Page records
206 */
207
208 /**
209 * @see DataSet/Assertion/createPageRecord.csv
210 */
211 public function createPage()
212 {
213 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
214 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
215 }
216
217 /**
218 * @see DataSet/Assertion/modifyPageRecord.csv
219 */
220 public function modifyPage()
221 {
222 $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1']);
223 }
224
225 /**
226 * @see DataSet/Assertion/deletePageRecord.csv
227 */
228 public function deletePage()
229 {
230 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
231 }
232
233 /**
234 * @see DataSet/Assertion/copyPageRecord.csv
235 */
236 public function copyPage()
237 {
238 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
239 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
240 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
241 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
242 }
243
244 /**
245 * @see DataSet/Assertion/localizePageRecord.csv
246 */
247 public function localizePage()
248 {
249 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
250 $this->recordIds['localizedPageOverlayId'] = $localizedTableIds[self::TABLE_PageOverlay][self::VALUE_PageId];
251 }
252
253 /**
254 * @see DataSet/Assertion/changePageRecordSorting.csv
255 */
256 public function changePageSorting()
257 {
258 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
259 }
260
261 /**
262 * @see DataSet/Assertion/movePageRecordToDifferentPage.csv
263 */
264 public function movePageToDifferentPage()
265 {
266 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
267 }
268
269 /**
270 * @see DataSet/Assertion/movePageRecordToDifferentPageAndChangeSorting.csv
271 */
272 public function movePageToDifferentPageAndChangeSorting()
273 {
274 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
275 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
276 }
277
278 /**
279 * @see DataSet/Assertion/movePageRecordToDifferentPageAndCreatePageRecordAfterMovedPageRecord.csv
280 * @see http://forge.typo3.org/issues/33104
281 * @see http://forge.typo3.org/issues/55573
282 */
283 public function movePageToDifferentPageAndCreatePageAfterMovedPage()
284 {
285 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
286 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, -self::VALUE_PageIdTarget, ['title' => 'Testing #1', 'hidden' => 0]);
287 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
288 }
289
290 /**
291 * Creates a content element and copies the page in draft workspace.
292 */
293 public function createContentAndCopyDraftPage()
294 {
295 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
296 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
297 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
298 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
299 }
300
301 /**
302 * Creates a content element and copies the page in live workspace.
303 */
304 public function createContentAndCopyLivePage()
305 {
306 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
307 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
308
309 // Switch to live workspace
310 $this->backendUser->workspace = 0;
311
312 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
313 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
314
315 // Switch back to draft workspace
316 $this->backendUser->workspace = static::VALUE_WorkspaceId;
317 }
318
319 /**
320 * Creates a page in a draft workspace and copies the parent page in draft workspace.
321 */
322 public function createPageAndCopyDraftParentPage()
323 {
324 $this->backendUser->uc['copyLevels'] = 10;
325
326 $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
327 $this->recordIds['newPageId'] = $newTableIds[static::TABLE_Page][0];
328 $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
329 $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
330 }
331 /**
332 * Creates a page in a draft workspace and copies the parent page in live workspace.
333 */
334 public function createPageAndCopyLiveParentPage()
335 {
336 $this->backendUser->uc['copyLevels'] = 10;
337
338 $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
339 $this->recordIds['newPageId'] = $newTableIds[static::TABLE_Page][0];
340
341 // Switch to live workspace
342 $this->backendUser->workspace = 0;
343
344 $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
345 $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
346
347 // Switch back to draft workspace
348 $this->backendUser->workspace = static::VALUE_WorkspaceId;
349 }
350
351 /**
352 * Creates nested pages in a draft workspace and copies the parent page in draft workspace.
353 */
354 public function createNestedPagesAndCopyDraftParentPage()
355 {
356 $this->backendUser->uc['copyLevels'] = 10;
357
358 $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
359 $this->recordIds['newPageIdFirst'] = $newTableIds[static::TABLE_Page][0];
360 $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, $this->recordIds['newPageIdFirst'], ['title' => 'Testing #2', 'hidden' => 0]);
361 $this->recordIds['newPageIdSecond'] = $newTableIds[static::TABLE_Page][0];
362 $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
363 $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
364 $this->recordIds['copiedPageIdFirst'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdFirst']];
365 $this->recordIds['copiedPageIdSecond'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdSecond']];
366 }
367
368 /**
369 * Creates nested pages in a draft workspace and copies the parent page in live workspace.
370 */
371 public function createNestedPagesAndCopyLiveParentPage()
372 {
373 $this->backendUser->uc['copyLevels'] = 10;
374
375 $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
376 $this->recordIds['newPageIdFirst'] = $newTableIds[static::TABLE_Page][0];
377 $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, $this->recordIds['newPageIdFirst'], ['title' => 'Testing #2', 'hidden' => 0]);
378 $this->recordIds['newPageIdSecond'] = $newTableIds[static::TABLE_Page][0];
379
380 // Switch to live workspace
381 $this->backendUser->workspace = 0;
382
383 $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
384 $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
385 $this->recordIds['copiedPageIdFirst'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdFirst']];
386 $this->recordIds['copiedPageIdSecond'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdSecond']];
387
388 // Switch back to draft workspace
389 $this->backendUser->workspace = static::VALUE_WorkspaceId;
390 }
391
392 /**
393 * Deletes a content element and copies the page in draft workspace
394 */
395 public function deleteContentAndCopyDraftPage()
396 {
397 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
398 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
399 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
400 }
401
402 /**
403 * Deletes a content element and copies the page in live workspace
404 */
405 public function deleteContentAndCopyLivePage()
406 {
407 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
408
409 // Switch to live workspace
410 $this->backendUser->workspace = 0;
411
412 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
413 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
414
415 // Switch back to draft workspace
416 $this->backendUser->workspace = static::VALUE_WorkspaceId;
417 }
418
419 /**
420 * Changes content sorting and copies the page in draft workspace.
421 */
422 public function changeContentSortingAndCopyDraftPage()
423 {
424 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
425 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
426 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
427 }
428
429 /**
430 * Changes content sorting and copies the page in live workspace.
431 */
432 public function changeContentSortingAndCopyLivePage()
433 {
434 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
435
436 // Switch to live workspace
437 $this->backendUser->workspace = 0;
438
439 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
440 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
441
442 // Switch back to draft workspace
443 $this->backendUser->workspace = static::VALUE_WorkspaceId;
444 }
445
446 /**
447 * Moves content either from and to the current page and copies the page in draft workspace.
448 */
449 public function moveContentAndCopyDraftPage()
450 {
451 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
452 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdZero, self::VALUE_PageId);
453 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
454 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
455 }
456
457 /**
458 * Moves content either from and to the current page and copies the page in draft workspace.
459 */
460 public function moveContentAndCopyLivePage()
461 {
462 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
463 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdZero, self::VALUE_PageId);
464
465 // Switch to live workspace
466 $this->backendUser->workspace = 0;
467
468 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
469 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
470
471 // Switch back to draft workspace
472 $this->backendUser->workspace = static::VALUE_WorkspaceId;
473 }
474
475 /**
476 * Creates new and move placeholders for pages and deleted the parent page in draft workspace.
477 */
478 public function createPlaceholdersAndDeleteDraftParentPage()
479 {
480 $this->backendUser->uc['recursiveDelete'] = true;
481
482 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
483 $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_ParentPageId, ['title' => 'Testing #1']);
484 $newTableIds = $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_ParentPageId);
485 $this->recordIds['deletedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_ParentPageId];
486 }
487
488 /**
489 * Creates new and move placeholders for pages and deleted the parent page in live workspace.
490 */
491 public function createPlaceholdersAndDeleteLiveParentPage()
492 {
493 $this->backendUser->uc['recursiveDelete'] = true;
494
495 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
496 $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_ParentPageId, ['title' => 'Testing #1']);
497
498 // Switch to live workspace
499 $this->backendUser->workspace = 0;
500
501 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_ParentPageId);
502
503 // Switch back to draft workspace
504 $this->backendUser->workspace = static::VALUE_WorkspaceId;
505 }
506 }