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 
32  const TABLE_Page = 'pages';
33  const TABLE_Content = 'tt_content';
34  const TABLE_Hotel = 'tx_irretutorial_1nff_hotel';
35  const TABLE_Offer = 'tx_irretutorial_1nff_offer';
36 
37  const FIELD_ContentHotel = 'tx_irretutorial_1nff_hotels';
38  const FIELD_HotelOffer = 'offers';
39 
43  protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/IRRE/ForeignField/DataSet/';
44 
45  protected function setUp()
46  {
47  parent::setUp();
48  $this->importScenarioDataSet('LiveDefaultPages');
49  $this->importScenarioDataSet('LiveDefaultElements');
50 
51  $this->setUpFrontendRootPage(
52  1,
53  [
54  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
55  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/ExtbaseJsonRenderer.ts',
56  ]
57  );
58  $this->backendUser->workspace = 0;
59  }
60 
68  public function createParentContent()
69  {
70  $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
71  }
72 
76  public function modifyParentContent()
77  {
78  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, ['header' => 'Testing #1']);
79  }
80 
84  public function deleteParentContent()
85  {
86  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
87  }
88 
92  public function copyParentContent()
93  {
94  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
95  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
96  }
97 
102  {
103  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
104  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
105  }
106 
111  {
112  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
113  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
114  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
115  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
116  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
117  }
118 
123  {
124  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
125  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
126  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
127  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
128  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
129  }
130 
135  {
136  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
137  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
138  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
139  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
140  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
141  }
142 
147  {
148  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
149  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
150  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
151  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
152  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
153  }
154 
159  {
160  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
161  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
162  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
163  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
164  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
165  }
166 
171  {
172  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
173  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
174  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
175  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
176  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
177  }
178 
183  {
184  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
185  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
186  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = false;
187  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
188  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
189  }
190 
195  {
196  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
197  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
198  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = true;
199  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
200  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
201  }
202 
206  public function changeParentContentSorting()
207  {
208  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
209  }
210 
215  {
216  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
217  }
218 
223  {
224  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
225  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
226  }
227 
235  public function modifyPage()
236  {
237  $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1']);
238  }
239 
243  public function deletePage()
244  {
245  $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
246  }
247 
251  public function copyPage()
252  {
253  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
254  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
255  }
256 
261  {
262  // Ensure hotels get processed first
263  $GLOBALS['TCA'] = array_merge(
264  [self::TABLE_Hotel => $GLOBALS['TCA'][self::TABLE_Hotel]],
265  $GLOBALS['TCA']
266  );
267 
268  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
269  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
270  }
271 
280  {
281  $newTableIds = $this->actionService->createNewRecords(
282  self::VALUE_PageId,
283  [
284  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
285  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
286  self::TABLE_Offer => ['title' => 'Offer #1'],
287  ]
288  );
289  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
290  }
291 
296  {
297  $newTableIds = $this->actionService->createNewRecords(
298  self::VALUE_PageId,
299  [
300  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
301  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
302  self::TABLE_Offer => ['title' => 'Offer #1'],
303  ]
304  );
305  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
306  $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
307  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
308  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
309  $this->recordIds['copiedHotelId'] = $copiedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
310  }
311 
316  {
317  $newTableIds = $this->actionService->createNewRecords(
318  self::VALUE_PageId,
319  [
320  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
321  self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
322  self::TABLE_Offer => ['title' => 'Offer #1'],
323  ]
324  );
325  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
326  $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
327  $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
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 
353  public function modifyOnlyHotelChild()
354  {
355  $this->actionService->modifyRecord(self::TABLE_Hotel, 4, ['title' => 'Testing #1']);
356  }
357 
362  {
363  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, [self::FIELD_ContentHotel => '4,3']);
364  }
365 
369  public function modifyParentWithHotelChild()
370  {
371  $this->actionService->modifyRecords(
372  self::VALUE_PageId,
373  [
374  self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'],
375  self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #1'],
376  ]
377  );
378  }
379 
384  {
385  $this->actionService->modifyRecords(
386  self::VALUE_PageId,
387  [
388  self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, self::FIELD_ContentHotel => '5,__nextUid'],
389  self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #2'],
390  ]
391  );
392  }
393 
398  {
399  $this->actionService->modifyRecord(
400  self::TABLE_Content,
401  self::VALUE_ContentIdFirst,
402  [self::FIELD_ContentHotel => '3'],
403  [self::TABLE_Hotel => [4]]
404  );
405  }
406 }
setUpFrontendRootPage($pageId, array $typoScriptFiles=[])
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']