TYPO3 CMS  TYPO3_7-6
AbstractActionTestCase.php
Go to the documentation of this file.
1 <?php
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 
21 {
22  const VALUE_ParentPageId = 88;
23  const VALUE_PageId = 89;
24  const VALUE_PageIdTarget = 90;
26  const VALUE_ContentIdZero = 296;
27  const VALUE_ContentIdFirst = 297;
28  const VALUE_ContentIdSecond = 298;
29  const VALUE_ContentIdThird = 299;
31 
32  const VALUE_ContentIdTenth = 310;
35 
36  const VALUE_LanguageId = 1;
38  const VALUE_WorkspaceId = 1;
39 
40  const TABLE_Page = 'pages';
41  const TABLE_PageOverlay = 'pages_language_overlay';
42  const TABLE_Content = 'tt_content';
43 
47  protected $coreExtensionsToLoad = [
48  'fluid',
49  'version',
50  'workspaces',
51  ];
52 
56  protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/';
57 
58  protected function setUp()
59  {
60  parent::setUp();
61  $this->importScenarioDataSet('LiveDefaultPages');
62  $this->importScenarioDataSet('LiveDefaultElements');
63  $this->importScenarioDataSet('ReferenceIndex');
64 
65  $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts']);
66  $this->backendUser->workspace = self::VALUE_WorkspaceId;
67  }
68 
76  public function createContents()
77  {
78  // Creating record at the beginning of the page
79  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
80  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][0];
81  // Creating record at the end of the page (after last one)
82  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, -self::VALUE_ContentIdSecond, ['header' => 'Testing #2']);
83  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][0];
84  }
85 
90  {
91  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
92  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
93  $versionedNewContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['newContentId']);
94  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedNewContentId);
95  }
96 
101  {
102  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
103  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
104  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
105  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
106  $versionedCopiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['copiedContentId']);
107  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId);
108  }
109 
113  public function modifyContent()
114  {
115  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, ['header' => 'Testing #1']);
116  }
117 
121  public function deleteContent()
122  {
123  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
124  }
125 
130  {
131  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized);
132  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdThird);
133  }
134 
138  public function copyContent()
139  {
140  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageId);
141  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
142  }
143 
147  public function copyContentToLanguage()
148  {
149  $copiedTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_LanguageId);
150  $this->recordIds['localizedContentId'] = $copiedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
151  }
152 
160  {
161  $copiedTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized, self::VALUE_LanguageIdSecond);
162  $this->recordIds['localizedContentId'] = $copiedTableIds[self::TABLE_Content][self::VALUE_ContentIdThirdLocalized];
163  }
164 
168  public function localizeContent()
169  {
170  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_LanguageId);
171  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
172  }
173 
178  {
179  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized, self::VALUE_LanguageIdSecond);
180  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdThirdLocalized];
181  }
182 
186  public function changeContentSorting()
187  {
188  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
189  }
190 
195  {
196  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
197  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
198  }
199 
204  {
205  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
206  // Switch to live workspace
207  $this->backendUser->workspace = 0;
208  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
209  // Switch back to draft workspace
210  $this->backendUser->workspace = static::VALUE_WorkspaceId;
211  }
212 
216  public function moveContentToDifferentPage()
217  {
218  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
219  }
220 
225  {
226  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
227  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
228  }
229 
237  public function createPage()
238  {
239  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
240  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
241  }
242 
246  public function modifyPage()
247  {
248  $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1']);
249  }
250 
254  public function deletePage()
255  {
256  $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
257  }
258 
262  public function deleteContentAndPage()
263  {
264  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
265  $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
266  }
267 
271  public function copyPage()
272  {
273  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
274  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
275  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
276  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
277  }
278 
283  public function copyPageFreeMode()
284  {
285  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdTarget);
286  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageIdTarget];
287  $this->recordIds['newContentIdTenth'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdTenth];
288  $this->recordIds['newContentIdTenthLocalized'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdTenthLocalized];
289  $this->recordIds['newContentIdTenthLocalized2'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdTenthLocalized2];
290  }
291 
295  public function localizePage()
296  {
297  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
298  $this->recordIds['localizedPageOverlayId'] = $localizedTableIds[self::TABLE_PageOverlay][self::VALUE_PageId];
299  }
300 
304  public function changePageSorting()
305  {
306  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
307  }
308 
312  public function movePageToDifferentPage()
313  {
314  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
315  }
316 
321  {
322  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
323  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
324  }
325 
332  {
333  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
334  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, -self::VALUE_PageIdTarget, ['title' => 'Testing #1', 'hidden' => 0]);
335  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
336  }
337 
342  {
343  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
344  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
345  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
346  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
347  }
348 
353  {
354  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
355  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
356 
357  // Switch to live workspace
358  $this->backendUser->workspace = 0;
359 
360  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
361  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
362 
363  // Switch back to draft workspace
364  $this->backendUser->workspace = static::VALUE_WorkspaceId;
365  }
366 
371  {
372  $this->backendUser->uc['copyLevels'] = 10;
373 
374  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
375  $this->recordIds['newPageId'] = $newTableIds[static::TABLE_Page][0];
376  $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
377  $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
378  }
383  {
384  $this->backendUser->uc['copyLevels'] = 10;
385 
386  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
387  $this->recordIds['newPageId'] = $newTableIds[static::TABLE_Page][0];
388 
389  // Switch to live workspace
390  $this->backendUser->workspace = 0;
391 
392  $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
393  $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
394 
395  // Switch back to draft workspace
396  $this->backendUser->workspace = static::VALUE_WorkspaceId;
397  }
398 
403  {
404  $this->backendUser->uc['copyLevels'] = 10;
405 
406  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
407  $this->recordIds['newPageIdFirst'] = $newTableIds[static::TABLE_Page][0];
408  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, $this->recordIds['newPageIdFirst'], ['title' => 'Testing #2', 'hidden' => 0]);
409  $this->recordIds['newPageIdSecond'] = $newTableIds[static::TABLE_Page][0];
410  $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
411  $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
412  $this->recordIds['copiedPageIdFirst'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdFirst']];
413  $this->recordIds['copiedPageIdSecond'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdSecond']];
414  }
415 
420  {
421  $this->backendUser->uc['copyLevels'] = 10;
422 
423  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
424  $this->recordIds['newPageIdFirst'] = $newTableIds[static::TABLE_Page][0];
425  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, $this->recordIds['newPageIdFirst'], ['title' => 'Testing #2', 'hidden' => 0]);
426  $this->recordIds['newPageIdSecond'] = $newTableIds[static::TABLE_Page][0];
427 
428  // Switch to live workspace
429  $this->backendUser->workspace = 0;
430 
431  $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
432  $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
433  $this->recordIds['copiedPageIdFirst'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdFirst']];
434  $this->recordIds['copiedPageIdSecond'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdSecond']];
435 
436  // Switch back to draft workspace
437  $this->backendUser->workspace = static::VALUE_WorkspaceId;
438  }
439 
444  {
445  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
446  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
447  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
448  }
449 
454  {
455  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
456 
457  // Switch to live workspace
458  $this->backendUser->workspace = 0;
459 
460  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
461  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
462 
463  // Switch back to draft workspace
464  $this->backendUser->workspace = static::VALUE_WorkspaceId;
465  }
466 
471  {
472  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
473  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
474  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
475  }
476 
481  {
482  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
483 
484  // Switch to live workspace
485  $this->backendUser->workspace = 0;
486 
487  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
488  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
489 
490  // Switch back to draft workspace
491  $this->backendUser->workspace = static::VALUE_WorkspaceId;
492  }
493 
497  public function moveContentAndCopyDraftPage()
498  {
499  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
500  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdZero, self::VALUE_PageId);
501  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
502  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
503  }
504 
508  public function moveContentAndCopyLivePage()
509  {
510  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
511  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdZero, self::VALUE_PageId);
512 
513  // Switch to live workspace
514  $this->backendUser->workspace = 0;
515 
516  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
517  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
518 
519  // Switch back to draft workspace
520  $this->backendUser->workspace = static::VALUE_WorkspaceId;
521  }
522 
527  {
528  $this->backendUser->uc['recursiveDelete'] = true;
529 
530  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
531  $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_ParentPageId, ['title' => 'Testing #1']);
532  $newTableIds = $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_ParentPageId);
533  $this->recordIds['deletedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_ParentPageId];
534  }
535 
540  {
541  $this->backendUser->uc['recursiveDelete'] = true;
542 
543  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
544  $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_ParentPageId, ['title' => 'Testing #1']);
545 
546  // Switch to live workspace
547  $this->backendUser->workspace = 0;
548 
549  $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_ParentPageId);
550 
551  // Switch back to draft workspace
552  $this->backendUser->workspace = static::VALUE_WorkspaceId;
553  }
554 }
setUpFrontendRootPage($pageId, array $typoScriptFiles=[])