TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
workspaces/Tests/Functional/DataHandling/IRRE/CSV/AbstractActionTestCase.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\IRRE\CSV;
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_PageId = 89;
23  const VALUE_PageIdTarget = 90;
25  const VALUE_ContentIdFirst = 297;
26  const VALUE_ContentIdLast = 298;
27  const VALUE_HotelIdFirst = 3;
29  const VALUE_HotelIdThird = 5;
30  const VALUE_LanguageId = 1;
31  const VALUE_WorkspaceId = 1;
32 
33  const TABLE_Page = 'pages';
34  const TABLE_Content = 'tt_content';
35  const TABLE_Hotel = 'tx_irretutorial_1ncsv_hotel';
36  const TABLE_Offer = 'tx_irretutorial_1ncsv_offer';
37 
38  const FIELD_ContentHotel = 'tx_irretutorial_1ncsv_hotels';
39  const FIELD_HotelOffer = 'offers';
40 
44  protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/IRRE/CSV/DataSet/';
45 
49  protected $coreExtensionsToLoad = [
50  'fluid',
51  'version',
52  'workspaces',
53  ];
54 
55  protected function setUp()
56  {
57  parent::setUp();
58  $this->importScenarioDataSet('LiveDefaultPages');
59  $this->importScenarioDataSet('LiveDefaultElements');
60  $this->importScenarioDataSet('ReferenceIndex');
61 
62  $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts']);
63  $this->backendUser->workspace = self::VALUE_WorkspaceId;
64  }
65 
73  public function createParentContent()
74  {
75  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
76  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
77  }
78 
82  public function modifyParentContent()
83  {
84  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, ['header' => 'Testing #1']);
85  }
86 
90  public function deleteParentContent()
91  {
92  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
93  }
94 
99  {
100  $newTableIds = $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
101  $versionedDeletedContentId = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
102  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedDeletedContentId);
103  }
104 
108  public function copyParentContent()
109  {
110  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
111  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
112  }
113 
118  {
119  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
120  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
121  }
122 
127  {
128  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
129  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
130  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
131  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
132  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
133  }
134 
139  {
140  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
141  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
142  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
143  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
144  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
145  }
146 
151  {
152  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
153  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
154  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
155  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
156  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
157  }
158 
163  {
164  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
165  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
166  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
167  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
168  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
169  }
170 
174  public function changeParentContentSorting()
175  {
176  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
177  }
178 
183  {
184  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
185  }
186 
191  {
192  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
193  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
194  }
195 
203  public function modifyPage()
204  {
205  $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1']);
206  }
207 
211  public function deletePage()
212  {
213  $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
214  }
215 
219  public function copyPage()
220  {
221  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
222  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
223  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
224  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
225  }
226 
232  {
233  // Ensure hotels get processed first
234  $GLOBALS['TCA'] = array_merge(
235  [self::TABLE_Hotel => $GLOBALS['TCA'][self::TABLE_Hotel]],
236  $GLOBALS['TCA']
237  );
238 
239  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
240  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
241  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
242  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
243  }
244 
253  {
254  $newTableIds = $this->actionService->createNewRecords(
255  self::VALUE_PageId,
256  [
257  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
258  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
259  self::TABLE_Offer => ['title' => 'Offer #1'],
260  ]
261  );
262  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
263  }
264 
269  {
270  // @todo Copying the new child records is broken in the Core
271  $newTableIds = $this->actionService->createNewRecords(
272  self::VALUE_PageId,
273  [
274  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
275  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
276  self::TABLE_Offer => ['title' => 'Offer #1'],
277  ]
278  );
279  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
280  $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
281  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
282  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
283  $this->recordIds['copiedHotelId'] = $copiedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
284  }
285 
290  {
291  // @todo Copying the new child records is broken in the Core
292  $newTableIds = $this->actionService->createNewRecords(
293  self::VALUE_PageId,
294  [
295  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
296  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
297  self::TABLE_Offer => ['title' => 'Offer #1'],
298  ]
299  );
300  $this->recordIds['newContentId'] = $newTableIds['tt_content'][0];
301  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
302  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
303  $versionedCopiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['copiedContentId']);
304  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId);
305  }
306 
311  {
312  // @todo Localizing the new child records is broken in the Core
313  $newTableIds = $this->actionService->createNewRecords(
314  self::VALUE_PageId,
315  [
316  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
317  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
318  self::TABLE_Offer => ['title' => 'Offer #1'],
319  ]
320  );
321  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
322  $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
323  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
324  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
325  $this->recordIds['localizedHotelId'] = $localizedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
326  }
327 
332  {
333  $newTableIds = $this->actionService->createNewRecords(
334  self::VALUE_PageId,
335  [
336  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
337  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
338  self::TABLE_Offer => ['title' => 'Offer #1'],
339  ]
340  );
341  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
342  $this->recordIds['versionedNewContentId'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['newContentId']);
343  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
344  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
345  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $this->recordIds['versionedNewContentId']);
346  }
347 
352  {
353  // @todo Localizing the new child records is broken in the Core
354  $newTableIds = $this->actionService->createNewRecords(
355  self::VALUE_PageId,
356  [
357  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
358  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
359  self::TABLE_Offer => ['title' => 'Offer #1'],
360  ]
361  );
362  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
363  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
364  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
365  $versionedLocalizedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['localizedContentId']);
366  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedLocalizedContentId);
367  }
368 
372  public function modifyOnlyHotelChild()
373  {
374  $this->actionService->modifyRecord(self::TABLE_Hotel, 4, ['title' => 'Testing #1']);
375  }
376 
381  {
382  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, [self::FIELD_ContentHotel => '4,3']);
383  }
384 
388  public function modifyParentWithHotelChild()
389  {
390  $this->actionService->modifyRecords(
391  self::VALUE_PageId,
392  [
393  self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'],
394  self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #1'],
395  ]
396  );
397  }
398 
403  {
404  $this->actionService->modifyRecords(
405  self::VALUE_PageId,
406  [
407  self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'],
408  self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #1'],
409  ]
410  );
411  $modifiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
412  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $modifiedContentId);
413  }
414 
419  {
420  $this->actionService->modifyRecords(
421  self::VALUE_PageId,
422  [
423  self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'],
424  self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #1'],
425  ]
426  );
427  $modifiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
428  $modifiedHotelId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Hotel, 4);
429  $this->actionService->clearWorkspaceRecords(
430  [
431  self::TABLE_Content => [$modifiedContentId],
432  self::TABLE_Hotel => [$modifiedHotelId],
433  ]
434  );
435  }
436 
441  {
442  $this->actionService->modifyRecords(
443  self::VALUE_PageId,
444  [
445  self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, self::FIELD_ContentHotel => '5,__nextUid'],
446  self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #2'],
447  ]
448  );
449  }
450 
455  {
456  $this->actionService->modifyRecord(
457  self::TABLE_Content,
458  self::VALUE_ContentIdFirst,
459  [self::FIELD_ContentHotel => '3'],
460  [self::TABLE_Hotel => [4]]
461  );
462  }
463 
468  {
469  $this->actionService->modifyRecords(
470  self::VALUE_PageId,
471  [
472  self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, 'header' => 'Testing #1', self::FIELD_ContentHotel => '3,4'],
473  self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #1'],
474  ]
475  );
476  $this->recordIds['versionedContentId'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
477  $this->recordIds['versionedHotelIdFirst'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Hotel, 3);
478  $this->recordIds['versionedHotelIdSecond'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Hotel, 4);
479  $this->actionService->clearWorkspaceRecords(
480  [
481  self::TABLE_Content => [$this->recordIds['versionedContentId']],
482  self::TABLE_Hotel => [$this->recordIds['versionedHotelIdSecond']],
483  ]
484  );
485  $this->actionService->modifyRecords(
486  self::VALUE_PageId,
487  [
488  self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, 'header' => 'Testing #2', self::FIELD_ContentHotel => '3,4'],
489  self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #2'],
490  ]
491  );
492  }
493 }
setUpFrontendRootPage($pageId, array $typoScriptFiles=[])
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']