e353d7d64b716082f93c977895ca6432e452a1e9
[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\Regular\AbstractActionTestCase
21 {
22 const VALUE_ParentPageId = 88;
23 const VALUE_ContentIdZero = 296;
24
25 const VALUE_ContentIdTenth = 310;
26 const VALUE_ContentIdTenthLocalized = 311;
27 const VALUE_ContentIdTenthLocalized2 = 312;
28
29 const VALUE_WorkspaceId = 1;
30
31 /**
32 * @var array
33 */
34 protected $coreExtensionsToLoad = [
35 'fluid',
36 'version',
37 'workspaces',
38 ];
39
40 /**
41 * @var string
42 */
43 protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/';
44
45 protected function setUp()
46 {
47 parent::setUp();
48 $this->importScenarioDataSet('ReferenceIndex');
49 $this->backendUser->workspace = self::VALUE_WorkspaceId;
50 }
51
52 /**
53 * Content records
54 */
55
56 /**
57 * @see DataSet/createContentRecordAndDiscardCreatedContentRecord.csv
58 */
59 public function createContentAndDiscardCreatedContent()
60 {
61 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
62 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
63 $versionedNewContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['newContentId']);
64 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedNewContentId);
65 }
66
67 /**
68 * @see DataSet/createAndCopyContentRecordAndDiscardCopiedContentRecord.csv
69 */
70 public function createAndCopyContentAndDiscardCopiedContent()
71 {
72 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
73 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
74 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
75 $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
76 $versionedCopiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['copiedContentId']);
77 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId);
78 }
79
80 /**
81 * @see DataSet/changeContentSortingNDeleteMovedRecord.csv
82 */
83 public function changeContentSortingAndDeleteMovedRecord()
84 {
85 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
86 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
87 }
88
89 /**
90 * @see DataSet/changeContentSortingNDeleteLiveRecord.csv
91 */
92 public function changeContentSortingAndDeleteLiveRecord()
93 {
94 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
95 // Switch to live workspace
96 $this->backendUser->workspace = 0;
97 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
98 // Switch back to draft workspace
99 $this->backendUser->workspace = static::VALUE_WorkspaceId;
100 }
101
102 /**
103 * Page records
104 */
105
106 /**
107 * @see DataSet/deleteContentAndPage.csv
108 */
109 public function deleteContentAndPage()
110 {
111 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
112 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
113 }
114
115 /**
116 * @see DataSet/copyPageFreeMode.csv
117 */
118 public function copyPageFreeMode()
119 {
120 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdTarget);
121 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageIdTarget];
122 $this->recordIds['newContentIdTenth'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdTenth];
123 $this->recordIds['newContentIdTenthLocalized'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdTenthLocalized];
124 $this->recordIds['newContentIdTenthLocalized2'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdTenthLocalized2];
125 }
126
127 /**
128 * @see DataSet/movePageRecordToDifferentPageAndCreatePageRecordAfterMovedPageRecord.csv
129 * @see http://forge.typo3.org/issues/33104
130 * @see http://forge.typo3.org/issues/55573
131 */
132 public function movePageToDifferentPageAndCreatePageAfterMovedPage()
133 {
134 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
135 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, -self::VALUE_PageIdTarget, ['title' => 'Testing #1', 'hidden' => 0]);
136 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
137 }
138
139 /**
140 * Creates a content element and copies the page in draft workspace.
141 */
142 public function createContentAndCopyDraftPage()
143 {
144 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
145 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
146 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
147 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
148 }
149
150 /**
151 * Creates a content element and copies the page in live workspace.
152 */
153 public function createContentAndCopyLivePage()
154 {
155 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
156 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
157
158 // Switch to live workspace
159 $this->backendUser->workspace = 0;
160
161 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
162 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
163
164 // Switch back to draft workspace
165 $this->backendUser->workspace = static::VALUE_WorkspaceId;
166 }
167
168 /**
169 * Creates a page in a draft workspace and copies the parent page in draft workspace.
170 */
171 public function createPageAndCopyDraftParentPage()
172 {
173 $this->backendUser->uc['copyLevels'] = 10;
174
175 $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
176 $this->recordIds['newPageId'] = $newTableIds[static::TABLE_Page][0];
177 $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
178 $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
179 }
180 /**
181 * Creates a page in a draft workspace and copies the parent page in live workspace.
182 */
183 public function createPageAndCopyLiveParentPage()
184 {
185 $this->backendUser->uc['copyLevels'] = 10;
186
187 $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
188 $this->recordIds['newPageId'] = $newTableIds[static::TABLE_Page][0];
189
190 // Switch to live workspace
191 $this->backendUser->workspace = 0;
192
193 $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
194 $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
195
196 // Switch back to draft workspace
197 $this->backendUser->workspace = static::VALUE_WorkspaceId;
198 }
199
200 /**
201 * Creates nested pages in a draft workspace and copies the parent page in draft workspace.
202 */
203 public function createNestedPagesAndCopyDraftParentPage()
204 {
205 $this->backendUser->uc['copyLevels'] = 10;
206
207 $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
208 $this->recordIds['newPageIdFirst'] = $newTableIds[static::TABLE_Page][0];
209 $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, $this->recordIds['newPageIdFirst'], ['title' => 'Testing #2', 'hidden' => 0]);
210 $this->recordIds['newPageIdSecond'] = $newTableIds[static::TABLE_Page][0];
211 $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
212 $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
213 $this->recordIds['copiedPageIdFirst'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdFirst']];
214 $this->recordIds['copiedPageIdSecond'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdSecond']];
215 }
216
217 /**
218 * Creates nested pages in a draft workspace and copies the parent page in live workspace.
219 */
220 public function createNestedPagesAndCopyLiveParentPage()
221 {
222 $this->backendUser->uc['copyLevels'] = 10;
223
224 $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
225 $this->recordIds['newPageIdFirst'] = $newTableIds[static::TABLE_Page][0];
226 $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, $this->recordIds['newPageIdFirst'], ['title' => 'Testing #2', 'hidden' => 0]);
227 $this->recordIds['newPageIdSecond'] = $newTableIds[static::TABLE_Page][0];
228
229 // Switch to live workspace
230 $this->backendUser->workspace = 0;
231
232 $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
233 $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
234 $this->recordIds['copiedPageIdFirst'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdFirst']];
235 $this->recordIds['copiedPageIdSecond'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdSecond']];
236
237 // Switch back to draft workspace
238 $this->backendUser->workspace = static::VALUE_WorkspaceId;
239 }
240
241 /**
242 * Deletes a content element and copies the page in draft workspace
243 */
244 public function deleteContentAndCopyDraftPage()
245 {
246 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
247 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
248 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
249 }
250
251 /**
252 * Deletes a content element and copies the page in live workspace
253 */
254 public function deleteContentAndCopyLivePage()
255 {
256 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
257
258 // Switch to live workspace
259 $this->backendUser->workspace = 0;
260
261 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
262 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
263
264 // Switch back to draft workspace
265 $this->backendUser->workspace = static::VALUE_WorkspaceId;
266 }
267
268 /**
269 * Changes content sorting and copies the page in draft workspace.
270 */
271 public function changeContentSortingAndCopyDraftPage()
272 {
273 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
274 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
275 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
276 }
277
278 /**
279 * Changes content sorting and copies the page in live workspace.
280 */
281 public function changeContentSortingAndCopyLivePage()
282 {
283 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
284
285 // Switch to live workspace
286 $this->backendUser->workspace = 0;
287
288 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
289 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
290
291 // Switch back to draft workspace
292 $this->backendUser->workspace = static::VALUE_WorkspaceId;
293 }
294
295 /**
296 * Moves content either from and to the current page and copies the page in draft workspace.
297 */
298 public function moveContentAndCopyDraftPage()
299 {
300 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
301 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdZero, self::VALUE_PageId);
302 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
303 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
304 }
305
306 /**
307 * Moves content either from and to the current page and copies the page in draft workspace.
308 */
309 public function moveContentAndCopyLivePage()
310 {
311 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
312 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdZero, self::VALUE_PageId);
313
314 // Switch to live workspace
315 $this->backendUser->workspace = 0;
316
317 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
318 $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
319
320 // Switch back to draft workspace
321 $this->backendUser->workspace = static::VALUE_WorkspaceId;
322 }
323
324 /**
325 * Creates new and move placeholders for pages and deleted the parent page in draft workspace.
326 */
327 public function createPlaceholdersAndDeleteDraftParentPage()
328 {
329 $this->backendUser->uc['recursiveDelete'] = true;
330
331 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
332 $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_ParentPageId, ['title' => 'Testing #1']);
333 $newTableIds = $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_ParentPageId);
334 $this->recordIds['deletedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_ParentPageId];
335 }
336
337 /**
338 * Creates new and move placeholders for pages and deleted the parent page in live workspace.
339 */
340 public function createPlaceholdersAndDeleteLiveParentPage()
341 {
342 $this->backendUser->uc['recursiveDelete'] = true;
343
344 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
345 $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_ParentPageId, ['title' => 'Testing #1']);
346
347 // Switch to live workspace
348 $this->backendUser->workspace = 0;
349
350 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_ParentPageId);
351
352 // Switch back to draft workspace
353 $this->backendUser->workspace = static::VALUE_WorkspaceId;
354 }
355 }