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_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_1nff_hotel';
36  const TABLE_Offer = 'tx_irretutorial_1nff_offer';
37 
38  const FIELD_ContentHotel = 'tx_irretutorial_1nff_hotels';
39  const FIELD_HotelOffer = 'offers';
40 
44  protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/IRRE/ForeignField/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(
63  1,
64  [
65  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
66  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/ExtbaseJsonRenderer.ts',
67  ]
68  );
69  $this->backendUser->workspace = self::VALUE_WorkspaceId;
70  }
71 
79  public function createParentContent()
80  {
81  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
82  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
83  }
84 
88  public function modifyParentContent()
89  {
90  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, ['header' => 'Testing #1']);
91  }
92 
96  public function deleteParentContent()
97  {
98  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
99  }
100 
105  {
106  $newTableIds = $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
107  $versionedDeletedContentId = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
108  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedDeletedContentId);
109  }
110 
114  public function copyParentContent()
115  {
116  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
117  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
118  }
119 
124  {
125  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
126  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
127  }
128 
133  {
134  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
135  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
136  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
137  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
138  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
139  }
140 
145  {
146  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
147  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
148  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
149  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
150  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
151  }
152 
157  {
158  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
159  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
160  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
161  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
162  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
163  }
164 
169  {
170  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
171  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
172  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
173  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
174  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
175  }
176 
180  public function changeParentContentSorting()
181  {
182  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
183  }
184 
189  {
190  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
191  }
192 
197  {
198  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
199  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
200  }
201 
209  public function modifyPage()
210  {
211  $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1']);
212  }
213 
217  public function deletePage()
218  {
219  $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
220  }
221 
225  public function copyPage()
226  {
227  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
228  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
229  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
230  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
231  }
232 
238  {
239  // Ensure hotels get processed first
240  $GLOBALS['TCA'] = array_merge(
241  [self::TABLE_Hotel => $GLOBALS['TCA'][self::TABLE_Hotel]],
242  $GLOBALS['TCA']
243  );
244 
245  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
246  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
247  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
248  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
249  }
250 
259  {
260  $newTableIds = $this->actionService->createNewRecords(
261  self::VALUE_PageId,
262  [
263  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
264  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
265  self::TABLE_Offer => ['title' => 'Offer #1'],
266  ]
267  );
268  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
269  }
270 
275  {
276  $newTableIds = $this->actionService->createNewRecords(
277  self::VALUE_PageId,
278  [
279  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
280  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
281  self::TABLE_Offer => ['title' => 'Offer #1'],
282  ]
283  );
284  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
285  $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
286  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
287  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
288  $this->recordIds['copiedHotelId'] = $copiedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
289  }
290 
295  {
296  $newTableIds = $this->actionService->createNewRecords(
297  self::VALUE_PageId,
298  [
299  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
300  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
301  self::TABLE_Offer => ['title' => 'Offer #1'],
302  ]
303  );
304  $this->recordIds['newContentId'] = $newTableIds['tt_content'][0];
305  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
306  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
307  $versionedCopiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['copiedContentId']);
308  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId);
309  }
310 
315  {
316  $newTableIds = $this->actionService->createNewRecords(
317  self::VALUE_PageId,
318  [
319  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
320  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
321  self::TABLE_Offer => ['title' => 'Offer #1'],
322  ]
323  );
324  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
325  $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
326  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
327  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
328  }
329 
334  {
335  unset($GLOBALS['TCA'][self::TABLE_Hotel]['ctrl']['sortby']);
336  $newTableIds = $this->actionService->createNewRecords(
337  self::VALUE_PageId,
338  [
339  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
340  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
341  self::TABLE_Offer => ['title' => 'Offer #1'],
342  ]
343  );
344  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
345  $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
346  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
347  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
348  }
349 
354  {
355  $newTableIds = $this->actionService->createNewRecords(
356  self::VALUE_PageId,
357  [
358  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
359  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
360  self::TABLE_Offer => ['title' => 'Offer #1'],
361  ]
362  );
363  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
364  $this->recordIds['versionedNewContentId'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['newContentId']);
365  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
366  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
367  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $this->recordIds['versionedNewContentId']);
368  }
369 
374  {
375  $newTableIds = $this->actionService->createNewRecords(
376  self::VALUE_PageId,
377  [
378  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
379  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
380  self::TABLE_Offer => ['title' => 'Offer #1'],
381  ]
382  );
383  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
384  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
385  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
386  $versionedLocalizedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['localizedContentId']);
387  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedLocalizedContentId);
388  }
389 
393  public function modifyOnlyHotelChild()
394  {
395  $this->actionService->modifyRecord(self::TABLE_Hotel, 4, ['title' => 'Testing #1']);
396  }
397 
402  {
403  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, [self::FIELD_ContentHotel => '4,3']);
404  }
405 
409  public function modifyParentWithHotelChild()
410  {
411  $this->actionService->modifyRecords(
412  self::VALUE_PageId,
413  [
414  self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'],
415  self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #1'],
416  ]
417  );
418  }
419 
424  {
425  $this->actionService->modifyRecords(
426  self::VALUE_PageId,
427  [
428  self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'],
429  self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #1'],
430  ]
431  );
432  $modifiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
433  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $modifiedContentId);
434  }
435 
440  {
441  $this->actionService->modifyRecords(
442  self::VALUE_PageId,
443  [
444  self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'],
445  self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #1'],
446  ]
447  );
448  $modifiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
449  $modifiedHotelId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Hotel, 4);
450  $this->actionService->clearWorkspaceRecords(
451  [
452  self::TABLE_Content => [$modifiedContentId],
453  self::TABLE_Hotel => [$modifiedHotelId],
454  ]
455  );
456  }
457 
462  {
463  $this->actionService->modifyRecords(
464  self::VALUE_PageId,
465  [
466  self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, self::FIELD_ContentHotel => '5,__nextUid'],
467  self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #2'],
468  ]
469  );
470  }
471 
476  {
477  $this->actionService->modifyRecord(
478  self::TABLE_Content,
479  self::VALUE_ContentIdFirst,
480  [self::FIELD_ContentHotel => '3'],
481  [self::TABLE_Hotel => [4]]
482  );
483  }
484 
489  {
490  $this->actionService->modifyRecords(
491  self::VALUE_PageId,
492  [
493  self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, 'header' => 'Testing #1', self::FIELD_ContentHotel => '3,4'],
494  self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #1'],
495  ]
496  );
497  $this->recordIds['versionedContentId'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
498  $this->recordIds['versionedHotelIdFirst'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Hotel, 3);
499  $this->recordIds['versionedHotelIdSecond'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Hotel, 4);
500  $this->actionService->clearWorkspaceRecords(
501  [
502  self::TABLE_Content => [$this->recordIds['versionedContentId']],
503  self::TABLE_Hotel => [$this->recordIds['versionedHotelIdSecond']],
504  ]
505  );
506  $this->actionService->modifyRecords(
507  self::VALUE_PageId,
508  [
509  self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, 'header' => 'Testing #2', self::FIELD_ContentHotel => '3,4'],
510  self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #2'],
511  ]
512  );
513  }
514 }
setUpFrontendRootPage($pageId, array $typoScriptFiles=[])
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']