TYPO3  7.6
Regular/AbstractActionTestCase.php
Go to the documentation of this file.
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 
20 abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
21 {
22  const VALUE_PageId = 89;
23  const VALUE_PageIdTarget = 90;
25  const VALUE_ContentIdFirst = 297;
26  const VALUE_ContentIdSecond = 298;
27  const VALUE_ContentIdThird = 299;
29  const VALUE_LanguageId = 1;
30  const VALUE_WorkspaceId = 1;
31 
32  const TABLE_Page = 'pages';
33  const TABLE_PageOverlay = 'pages_language_overlay';
34  const TABLE_Content = 'tt_content';
35 
39  protected $coreExtensionsToLoad = array(
40  'fluid',
41  'version',
42  'workspaces',
43  );
44 
48  protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/';
49 
50  protected function setUp()
51  {
52  parent::setUp();
53  $this->importScenarioDataSet('LiveDefaultPages');
54  $this->importScenarioDataSet('LiveDefaultElements');
55  $this->importScenarioDataSet('ReferenceIndex');
56 
57  $this->setUpFrontendRootPage(1, array('typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts'));
58  $this->backendUser->workspace = self::VALUE_WorkspaceId;
59  }
60 
68  public function createContents()
69  {
70  // Creating record at the beginning of the page
71  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
72  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][0];
73  // Creating record at the end of the page (after last one)
74  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, -self::VALUE_ContentIdSecond, array('header' => 'Testing #2'));
75  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][0];
76  }
77 
82  {
83  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
84  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
85  $versionedNewContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['newContentId']);
86  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedNewContentId);
87  }
88 
93  {
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  {
107  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, array('header' => 'Testing #1'));
108  }
109 
113  public function deleteContent()
114  {
115  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
116  }
117 
122  {
123  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized);
124  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdThird);
125  }
126 
130  public function copyContent()
131  {
132  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageId);
133  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
134  }
135 
139  public function localizeContent()
140  {
141  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_LanguageId);
142  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
143  }
144 
148  public function changeContentSorting()
149  {
150  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
151  }
152 
157  {
158  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
159  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
160  }
161 
166  {
167  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
168  // Switch to live workspace
169  $this->backendUser->workspace = 0;
170  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
171  // Switch back to draft workspace
172  $this->backendUser->workspace = static::VALUE_WorkspaceId;
173  }
174 
178  public function moveContentToDifferentPage()
179  {
180  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
181  }
182 
187  {
188  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
189  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
190  }
191 
199  public function createPage()
200  {
201  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1', 'hidden' => 0));
202  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
203  }
204 
208  public function modifyPage()
209  {
210  $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1'));
211  }
212 
216  public function deletePage()
217  {
218  $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
219  }
220 
224  public function copyPage()
225  {
226  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
227  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
228  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
229  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
230  }
231 
235  public function localizePage()
236  {
237  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
238  $this->recordIds['localizedPageOverlayId'] = $localizedTableIds[self::TABLE_PageOverlay][self::VALUE_PageId];
239  }
240 
244  public function changePageSorting()
245  {
246  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
247  }
248 
252  public function movePageToDifferentPage()
253  {
254  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
255  }
256 
261  {
262  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
263  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
264  }
265 
272  {
273  $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
274  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, -self::VALUE_PageIdTarget, array('title' => 'Testing #1', 'hidden' => 0));
275  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
276  }
277 
282  {
283  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
284  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
285  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
286  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
287  }
288 
293  {
294  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
295  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
296 
297  // Switch to live workspace
298  $this->backendUser->workspace = 0;
299 
300  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
301  $this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
302 
303  // Switch back to draft workspace
304  $this->backendUser->workspace = static::VALUE_WorkspaceId;
305  }
306 
311  {
312  $this->backendUser->uc['copyLevels'] = 10;
313 
314  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, array('title' => 'Testing #1', 'hidden' => 0));
315  $this->recordIds['newPageId'] = $newTableIds[static::TABLE_Page][0];
316  $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
317  $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
318  }
323  {
324  $this->backendUser->uc['copyLevels'] = 10;
325 
326  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, array('title' => 'Testing #1', 'hidden' => 0));
327  $this->recordIds['newPageId'] = $newTableIds[static::TABLE_Page][0];
328 
329  // Switch to live workspace
330  $this->backendUser->workspace = 0;
331 
332  $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
333  $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
334 
335  // Switch back to draft workspace
336  $this->backendUser->workspace = static::VALUE_WorkspaceId;
337  }
338 
343  {
344  $this->backendUser->uc['copyLevels'] = 10;
345 
346  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, array('title' => 'Testing #1', 'hidden' => 0));
347  $this->recordIds['newPageIdFirst'] = $newTableIds[static::TABLE_Page][0];
348  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, $this->recordIds['newPageIdFirst'], array('title' => 'Testing #2', 'hidden' => 0));
349  $this->recordIds['newPageIdSecond'] = $newTableIds[static::TABLE_Page][0];
350  $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
351  $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
352  $this->recordIds['copiedPageIdFirst'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdFirst']];
353  $this->recordIds['copiedPageIdSecond'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdSecond']];
354  }
355 
360  {
361  $this->backendUser->uc['copyLevels'] = 10;
362 
363  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, array('title' => 'Testing #1', 'hidden' => 0));
364  $this->recordIds['newPageIdFirst'] = $newTableIds[static::TABLE_Page][0];
365  $newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, $this->recordIds['newPageIdFirst'], array('title' => 'Testing #2', 'hidden' => 0));
366  $this->recordIds['newPageIdSecond'] = $newTableIds[static::TABLE_Page][0];
367 
368  // Switch to live workspace
369  $this->backendUser->workspace = 0;
370 
371  $newTableIds = $this->actionService->copyRecord(static::TABLE_Page, static::VALUE_PageId, static::VALUE_PageIdTarget);
372  $this->recordIds['copiedPageId'] = $newTableIds[static::TABLE_Page][static::VALUE_PageId];
373  $this->recordIds['copiedPageIdFirst'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdFirst']];
374  $this->recordIds['copiedPageIdSecond'] = $newTableIds[static::TABLE_Page][$this->recordIds['newPageIdSecond']];
375 
376  // Switch back to draft workspace
377  $this->backendUser->workspace = static::VALUE_WorkspaceId;
378  }
379 
380 }