TYPO3 CMS  TYPO3_6-2
AbstractActionTestCase.php
Go to the documentation of this file.
1 <?php
3 
17 require_once __DIR__ . '/../../../../../core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php';
18 
23 
24  const VALUE_ParentPageId = 88;
25  const VALUE_PageId = 89;
26  const VALUE_PageIdTarget = 90;
28  const VALUE_ContentIdZero = 296;
29  const VALUE_ContentIdFirst = 297;
30  const VALUE_ContentIdSecond = 298;
31  const VALUE_ContentIdThird = 299;
33  const VALUE_LanguageId = 1;
34  const VALUE_WorkspaceId = 1;
35 
36  const TABLE_Page = 'pages';
37  const TABLE_PageOverlay = 'pages_language_overlay';
38  const TABLE_Content = 'tt_content';
39 
43  protected $coreExtensionsToLoad = array(
44  'fluid',
45  'version',
46  'workspaces',
47  );
48 
52  protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/';
53 
54  public function setUp() {
55  parent::setUp();
56  $this->importScenarioDataSet('LiveDefaultPages');
57  $this->importScenarioDataSet('LiveDefaultElements');
58  $this->importScenarioDataSet('ReferenceIndex');
59 
60  $this->setUpFrontendRootPage(1, array('typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts'));
61  $this->backendUser->workspace = self::VALUE_WorkspaceId;
62  }
63 
71  public function createContents() {
72  // Creating record at the beginning of the page
73  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
74  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][0];
75  // Creating record at the end of the page (after last one)
76  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, -self::VALUE_ContentIdSecond, array('header' => 'Testing #2'));
77  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][0];
78  }
79 
84  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
85  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
86  $versionedNewContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['newContentId']);
87  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedNewContentId);
88  }
89 
94  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
95  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
96  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
97  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
98  $versionedCopiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['copiedContentId']);
99  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId);
100  }
101 
105  public function modifyContent() {
106  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, array('header' => 'Testing #1'));
107  }
108 
112  public function deleteContent() {
113  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
114  }
115 
120  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized);
121  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdThird);
122  }
123 
127  public function copyContent() {
128  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageId);
129  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
130  }
131 
135  public function localizeContent() {
136  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_LanguageId);
137  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
138  }
139 
143  public function changeContentSorting() {
144  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
145  }
146 
151  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
152  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
153  }
154 
159  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
160  // Switch to live workspace
161  $this->backendUser->workspace = 0;
162  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
163  // Switch back to draft workspace
164  $this->backendUser->workspace = static::VALUE_WorkspaceId;
165  }
166 
170  public function moveContentToDifferentPage() {
171  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
172  }
173 
178  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
179  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
180  }
181 
189  public function createPage() {
190  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1', 'hidden' => 0));
191  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
192  }
193 
197  public function modifyPage() {
198  $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1'));
199  }
200 
204  public function deletePage() {
205  $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
206  }
207 
211  public function copyPage() {
212  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
213  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
214  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
215  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
216  }
217 
221  public function localizePage() {
222  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
223  $this->recordIds['localizedPageOverlayId'] = $localizedTableIds[self::TABLE_PageOverlay][self::VALUE_PageId];
224  }
225 
229  public function changePageSorting() {
230  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
231  }
232 
236  public function movePageToDifferentPage() {
237  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
238  }
239 
244  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
245  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
246  }
247 
254  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
255  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, -self::VALUE_PageIdTarget, array('title' => 'Testing #1', 'hidden' => 0));
256  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
257  }
258 
262  public function createContentAndCopyDraftPage() {
263  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
264  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
265  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
266  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
267  }
268 
272  public function createContentAndCopyLivePage() {
273  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
274  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
275 
276  // Switch to live workspace
277  $this->backendUser->workspace = 0;
278 
279  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
280  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
281 
282  // Switch back to draft workspace
283  $this->backendUser->workspace = static::VALUE_WorkspaceId;
284  }
285 
290  $this->backendUser->uc['copyLevels'] = 10;
291 
292  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, array('title' => 'Testing #1', 'hidden' => 0));
293  $this->recordIds['newPageId'] = $newTableIds[static::TABLE_Page][0];
294  $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
295  $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
296  }
301  $this->backendUser->uc['copyLevels'] = 10;
302 
303  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, array('title' => 'Testing #1', 'hidden' => 0));
304  $this->recordIds['newPageId'] = $newTableIds[static::TABLE_Page][0];
305 
306  // Switch to live workspace
307  $this->backendUser->workspace = 0;
308 
309  $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
310  $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
311 
312  // Switch back to draft workspace
313  $this->backendUser->workspace = static::VALUE_WorkspaceId;
314  }
315 
320  $this->backendUser->uc['copyLevels'] = 10;
321 
322  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, array('title' => 'Testing #1', 'hidden' => 0));
323  $this->recordIds['newPageIdFirst'] = $newTableIds[static::TABLE_Page][0];
324  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, $this->recordIds['newPageIdFirst'], array('title' => 'Testing #2', 'hidden' => 0));
325  $this->recordIds['newPageIdSecond'] = $newTableIds[static::TABLE_Page][0];
326  $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
327  $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
328  $this->recordIds['copiedPageIdFirst'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdFirst']];
329  $this->recordIds['copiedPageIdSecond'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdSecond']];
330  }
331 
336  $this->backendUser->uc['copyLevels'] = 10;
337 
338  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, array('title' => 'Testing #1', 'hidden' => 0));
339  $this->recordIds['newPageIdFirst'] = $newTableIds[static::TABLE_Page][0];
340  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, $this->recordIds['newPageIdFirst'], array('title' => 'Testing #2', 'hidden' => 0));
341  $this->recordIds['newPageIdSecond'] = $newTableIds[static::TABLE_Page][0];
342 
343  // Switch to live workspace
344  $this->backendUser->workspace = 0;
345 
346  $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
347  $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
348  $this->recordIds['copiedPageIdFirst'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdFirst']];
349  $this->recordIds['copiedPageIdSecond'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdSecond']];
350 
351  // Switch back to draft workspace
352  $this->backendUser->workspace = static::VALUE_WorkspaceId;
353  }
354 
358  public function deleteContentAndCopyDraftPage() {
359  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
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 
367  public function deleteContentAndCopyLivePage() {
368  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
369 
370  // Switch to live workspace
371  $this->backendUser->workspace = 0;
372 
373  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
374  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
375 
376  // Switch back to draft workspace
377  $this->backendUser->workspace = static::VALUE_WorkspaceId;
378  }
379 
384  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
385  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
386  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
387  }
388 
393  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
394 
395  // Switch to live workspace
396  $this->backendUser->workspace = 0;
397 
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  // Switch back to draft workspace
402  $this->backendUser->workspace = static::VALUE_WorkspaceId;
403  }
404 
408  public function moveContentAndCopyDraftPage() {
409  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
410  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdZero, self::VALUE_PageId);
411  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
412  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
413  }
414 
418  public function moveContentAndCopyLivePage() {
419  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
420  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdZero, self::VALUE_PageId);
421 
422  // Switch to live workspace
423  $this->backendUser->workspace = 0;
424 
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  // Switch back to draft workspace
429  $this->backendUser->workspace = static::VALUE_WorkspaceId;
430  }
431 
436  $this->backendUser->uc['recursiveDelete'] = TRUE;
437 
438  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
439  $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_ParentPageId, array('title' => 'Testing #1'));
440  $newTableIds = $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_ParentPageId);
441  $this->recordIds['deletedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_ParentPageId];
442  }
443 
448  $this->backendUser->uc['recursiveDelete'] = TRUE;
449 
450  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
451  $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_ParentPageId, array('title' => 'Testing #1'));
452 
453  // Switch to live workspace
454  $this->backendUser->workspace = 0;
455 
456  $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_ParentPageId);
457 
458  // Switch back to draft workspace
459  $this->backendUser->workspace = static::VALUE_WorkspaceId;
460  }
461 
462 }
setUpFrontendRootPage($pageId, array $typoScriptFiles=array())