2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Regular
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
18 * Functional test for the DataHandler
20 abstract class AbstractActionTestCase
extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
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;
35 const TABLE_Page
= 'pages';
36 const TABLE_PageOverlay
= 'pages_language_overlay';
37 const TABLE_Content
= 'tt_content';
42 protected $coreExtensionsToLoad = [
51 protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/';
53 protected function setUp()
56 $this->importScenarioDataSet('LiveDefaultPages');
57 $this->importScenarioDataSet('LiveDefaultElements');
58 $this->importScenarioDataSet('ReferenceIndex');
60 $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts']);
61 $this->backendUser
->workspace
= self
::VALUE_WorkspaceId
;
69 * @see DataSet/Assertion/createContentRecords.csv
71 public function createContents()
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];
82 * @see DataSet/Assertion/createContentRecordAndDiscardCreatedContentRecord.csv
84 public function createContentAndDiscardCreatedContent()
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);
93 * @see DataSet/Assertion/createAndCopyContentRecordAndDiscardCopiedContentRecord.csv
95 public function createAndCopyContentAndDiscardCopiedContent()
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);
106 * @see DataSet/Assertion/modifyContentRecord.csv
108 public function modifyContent()
110 $this->actionService
->modifyRecord(self
::TABLE_Content
, self
::VALUE_ContentIdSecond
, ['header' => 'Testing #1']);
114 * @see DataSet/Assertion/deleteContentRecord.csv
116 public function deleteContent()
118 $this->actionService
->deleteRecord(self
::TABLE_Content
, self
::VALUE_ContentIdSecond
);
122 * @see DataSet/deleteLocalizedContentNDeleteContent.csv
124 public function deleteLocalizedContentAndDeleteContent()
126 $this->actionService
->deleteRecord(self
::TABLE_Content
, self
::VALUE_ContentIdThirdLocalized
);
127 $this->actionService
->deleteRecord(self
::TABLE_Content
, self
::VALUE_ContentIdThird
);
131 * @see DataSet/Assertion/copyContentRecord.csv
133 public function copyContent()
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
];
140 * @see DataSet/Assertion/localizeContentRecord.csv
142 public function localizeContent()
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
];
149 * @see DataSet/Assertion/localizeContentRecord.csv
151 public function localizeContentFromNonDefaultLanguage()
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
];
158 * @see DataSet/Assertion/changeContentRecordSorting.csv
160 public function changeContentSorting()
162 $this->actionService
->moveRecord(self
::TABLE_Content
, self
::VALUE_ContentIdFirst
, -self
::VALUE_ContentIdSecond
);
166 * @see DataSet/changeContentSortingNDeleteMovedRecord.csv
168 public function changeContentSortingAndDeleteMovedRecord()
170 $this->actionService
->moveRecord(self
::TABLE_Content
, self
::VALUE_ContentIdFirst
, -self
::VALUE_ContentIdSecond
);
171 $this->actionService
->deleteRecord(self
::TABLE_Content
, self
::VALUE_ContentIdFirst
);
175 * @see DataSet/changeContentSortingNDeleteLiveRecord.csv
177 public function changeContentSortingAndDeleteLiveRecord()
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
;
188 * @see DataSet/Assertion/moveContentRecordToDifferentPage.csv
190 public function moveContentToDifferentPage()
192 $this->actionService
->moveRecord(self
::TABLE_Content
, self
::VALUE_ContentIdSecond
, self
::VALUE_PageIdTarget
);
196 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
198 public function moveContentToDifferentPageAndChangeSorting()
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
);
209 * @see DataSet/Assertion/createPageRecord.csv
211 public function createPage()
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];
218 * @see DataSet/Assertion/modifyPageRecord.csv
220 public function modifyPage()
222 $this->actionService
->modifyRecord(self
::TABLE_Page
, self
::VALUE_PageId
, ['title' => 'Testing #1']);
226 * @see DataSet/Assertion/deletePageRecord.csv
228 public function deletePage()
230 $this->actionService
->deleteRecord(self
::TABLE_Page
, self
::VALUE_PageId
);
234 * @see DataSet/Assertion/copyPageRecord.csv
236 public function copyPage()
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
];
245 * @see DataSet/Assertion/localizePageRecord.csv
247 public function localizePage()
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
];
254 * @see DataSet/Assertion/changePageRecordSorting.csv
256 public function changePageSorting()
258 $this->actionService
->moveRecord(self
::TABLE_Page
, self
::VALUE_PageId
, -self
::VALUE_PageIdTarget
);
262 * @see DataSet/Assertion/movePageRecordToDifferentPage.csv
264 public function movePageToDifferentPage()
266 $this->actionService
->moveRecord(self
::TABLE_Page
, self
::VALUE_PageId
, self
::VALUE_PageIdTarget
);
270 * @see DataSet/Assertion/movePageRecordToDifferentPageAndChangeSorting.csv
272 public function movePageToDifferentPageAndChangeSorting()
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
);
279 * @see DataSet/Assertion/movePageRecordToDifferentPageAndCreatePageRecordAfterMovedPageRecord.csv
280 * @see http://forge.typo3.org/issues/33104
281 * @see http://forge.typo3.org/issues/55573
283 public function movePageToDifferentPageAndCreatePageAfterMovedPage()
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];
291 * Creates a content element and copies the page in draft workspace.
293 public function createContentAndCopyDraftPage()
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
];
302 * Creates a content element and copies the page in live workspace.
304 public function createContentAndCopyLivePage()
306 $newTableIds = $this->actionService
->createNewRecord(self
::TABLE_Content
, self
::VALUE_PageId
, ['header' => 'Testing #1']);
307 $this->recordIds
['newContentId'] = $newTableIds[self
::TABLE_Content
][0];
309 // Switch to live workspace
310 $this->backendUser
->workspace
= 0;
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
];
315 // Switch back to draft workspace
316 $this->backendUser
->workspace
= static::VALUE_WorkspaceId
;
320 * Creates a page in a draft workspace and copies the parent page in draft workspace.
322 public function createPageAndCopyDraftParentPage()
324 $this->backendUser
->uc
['copyLevels'] = 10;
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
];
332 * Creates a page in a draft workspace and copies the parent page in live workspace.
334 public function createPageAndCopyLiveParentPage()
336 $this->backendUser
->uc
['copyLevels'] = 10;
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];
341 // Switch to live workspace
342 $this->backendUser
->workspace
= 0;
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
];
347 // Switch back to draft workspace
348 $this->backendUser
->workspace
= static::VALUE_WorkspaceId
;
352 * Creates nested pages in a draft workspace and copies the parent page in draft workspace.
354 public function createNestedPagesAndCopyDraftParentPage()
356 $this->backendUser
->uc
['copyLevels'] = 10;
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']];
369 * Creates nested pages in a draft workspace and copies the parent page in live workspace.
371 public function createNestedPagesAndCopyLiveParentPage()
373 $this->backendUser
->uc
['copyLevels'] = 10;
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];
380 // Switch to live workspace
381 $this->backendUser
->workspace
= 0;
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']];
388 // Switch back to draft workspace
389 $this->backendUser
->workspace
= static::VALUE_WorkspaceId
;
393 * Deletes a content element and copies the page in draft workspace
395 public function deleteContentAndCopyDraftPage()
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
];
403 * Deletes a content element and copies the page in live workspace
405 public function deleteContentAndCopyLivePage()
407 $this->actionService
->deleteRecord(self
::TABLE_Content
, self
::VALUE_ContentIdSecond
);
409 // Switch to live workspace
410 $this->backendUser
->workspace
= 0;
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
];
415 // Switch back to draft workspace
416 $this->backendUser
->workspace
= static::VALUE_WorkspaceId
;
420 * Changes content sorting and copies the page in draft workspace.
422 public function changeContentSortingAndCopyDraftPage()
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
];
430 * Changes content sorting and copies the page in live workspace.
432 public function changeContentSortingAndCopyLivePage()
434 $this->actionService
->moveRecord(self
::TABLE_Content
, self
::VALUE_ContentIdFirst
, -self
::VALUE_ContentIdSecond
);
436 // Switch to live workspace
437 $this->backendUser
->workspace
= 0;
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
];
442 // Switch back to draft workspace
443 $this->backendUser
->workspace
= static::VALUE_WorkspaceId
;
447 * Moves content either from and to the current page and copies the page in draft workspace.
449 public function moveContentAndCopyDraftPage()
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
];
458 * Moves content either from and to the current page and copies the page in draft workspace.
460 public function moveContentAndCopyLivePage()
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
);
465 // Switch to live workspace
466 $this->backendUser
->workspace
= 0;
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
];
471 // Switch back to draft workspace
472 $this->backendUser
->workspace
= static::VALUE_WorkspaceId
;
476 * Creates new and move placeholders for pages and deleted the parent page in draft workspace.
478 public function createPlaceholdersAndDeleteDraftParentPage()
480 $this->backendUser
->uc
['recursiveDelete'] = true
;
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
];
489 * Creates new and move placeholders for pages and deleted the parent page in live workspace.
491 public function createPlaceholdersAndDeleteLiveParentPage()
493 $this->backendUser
->uc
['recursiveDelete'] = true
;
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']);
498 // Switch to live workspace
499 $this->backendUser
->workspace
= 0;
501 $this->actionService
->deleteRecord(self
::TABLE_Page
, self
::VALUE_ParentPageId
);
503 // Switch back to draft workspace
504 $this->backendUser
->workspace
= static::VALUE_WorkspaceId
;