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_PageId = 89;
25  const VALUE_PageIdTarget = 90;
27  const VALUE_ContentIdFirst = 297;
28  const VALUE_ContentIdLast = 298;
29  const VALUE_HotelIdFirst = 3;
31  const VALUE_HotelIdThird = 5;
32  const VALUE_LanguageId = 1;
33  const VALUE_WorkspaceId = 1;
34 
35  const TABLE_Page = 'pages';
36  const TABLE_Content = 'tt_content';
37  const TABLE_Hotel = 'tx_irretutorial_1nff_hotel';
38  const TABLE_Offer = 'tx_irretutorial_1nff_offer';
39 
40  const FIELD_ContentHotel = 'tx_irretutorial_1nff_hotels';
41  const FIELD_HotelOffer = 'offers';
42 
46  protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/IRRE/ForeignField/DataSet/';
47 
51  protected $coreExtensionsToLoad = array(
52  'fluid',
53  'version',
54  'workspaces',
55  );
56 
57  public function setUp() {
58  parent::setUp();
59  $this->importScenarioDataSet('LiveDefaultPages');
60  $this->importScenarioDataSet('LiveDefaultElements');
61  $this->importScenarioDataSet('ReferenceIndex');
62 
63  $this->setUpFrontendRootPage(
64  1,
65  array(
66  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
67  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/ExtbaseJsonRenderer.ts',
68  )
69  );
70  $this->backendUser->workspace = self::VALUE_WorkspaceId;
71  }
72 
80  public function createParentContent() {
81  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
82  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
83  }
84 
88  public function modifyParentContent() {
89  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, array('header' => 'Testing #1'));
90  }
91 
95  public function deleteParentContent() {
96  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
97  }
98 
103  $newTableIds = $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
104  $versionedDeletedContentId = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
105  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedDeletedContentId);
106  }
107 
111  public function copyParentContent() {
112  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
113  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
114  }
115 
120  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
121  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
122  }
123 
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  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
140  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = TRUE;
141  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = TRUE;
142  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
143  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
144  }
145 
150  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
151  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = FALSE;
152  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = FALSE;
153  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
154  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
155  }
156 
161  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
162  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = TRUE;
163  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = TRUE;
164  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
165  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
166  }
167 
171  public function changeParentContentSorting() {
172  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
173  }
174 
179  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
180  }
181 
186  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
187  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
188  }
189 
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_ContentIdLast];
216  }
217 
223  // Ensure hotels get processed first
224  $GLOBALS['TCA'] = array_merge(
225  array(self::TABLE_Hotel => $GLOBALS['TCA'][self::TABLE_Hotel]),
226  $GLOBALS['TCA']
227  );
228 
229  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
230  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
231  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
232  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
233  }
234 
243  $newTableIds = $this->actionService->createNewRecords(
244  self::VALUE_PageId,
245  array(
246  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
247  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
248  self::TABLE_Offer => array('title' => 'Offer #1'),
249  )
250  );
251  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
252  }
253 
258  $newTableIds = $this->actionService->createNewRecords(
259  self::VALUE_PageId,
260  array(
261  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
262  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
263  self::TABLE_Offer => array('title' => 'Offer #1'),
264  )
265  );
266  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
267  $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
268  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
269  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
270  $this->recordIds['copiedHotelId'] = $copiedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
271  }
272 
277  $newTableIds = $this->actionService->createNewRecords(
278  self::VALUE_PageId,
279  array(
280  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
281  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
282  self::TABLE_Offer => array('title' => 'Offer #1'),
283  )
284  );
285  $this->recordIds['newContentId'] = $newTableIds['tt_content'][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  $versionedCopiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['copiedContentId']);
289  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId);
290  }
291 
296  $newTableIds = $this->actionService->createNewRecords(
297  self::VALUE_PageId,
298  array(
299  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
300  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
301  self::TABLE_Offer => array('title' => 'Offer #1'),
302  )
303  );
304  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
305  $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
306  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
307  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
308  }
309 
314  unset($GLOBALS['TCA'][self::TABLE_Hotel]['ctrl']['sortby']);
315  $newTableIds = $this->actionService->createNewRecords(
316  self::VALUE_PageId,
317  array(
318  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
319  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
320  self::TABLE_Offer => array('title' => 'Offer #1'),
321  )
322  );
323  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
324  $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
325  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
326  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
327  }
328 
333  $newTableIds = $this->actionService->createNewRecords(
334  self::VALUE_PageId,
335  array(
336  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
337  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
338  self::TABLE_Offer => array('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  $newTableIds = $this->actionService->createNewRecords(
353  self::VALUE_PageId,
354  array(
355  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
356  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
357  self::TABLE_Offer => array('title' => 'Offer #1'),
358  )
359  );
360  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
361  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
362  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
363  $versionedLocalizedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['localizedContentId']);
364  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedLocalizedContentId);
365  }
366 
370  public function modifyOnlyHotelChild() {
371  $this->actionService->modifyRecord(self::TABLE_Hotel, 4, array('title' => 'Testing #1'));
372  }
373 
378  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array(self::FIELD_ContentHotel => '4,3'));
379  }
380 
384  public function modifyParentWithHotelChild() {
385  $this->actionService->modifyRecords(
386  self::VALUE_PageId,
387  array(
388  self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'),
389  self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
390  )
391  );
392  }
393 
398  $this->actionService->modifyRecords(
399  self::VALUE_PageId,
400  array(
401  self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'),
402  self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
403  )
404  );
405  $modifiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
406  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $modifiedContentId);
407  }
408 
413  $this->actionService->modifyRecords(
414  self::VALUE_PageId,
415  array(
416  self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'),
417  self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
418  )
419  );
420  $modifiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
421  $modifiedHotelId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Hotel, 4);
422  $this->actionService->clearWorkspaceRecords(
423  array(
424  self::TABLE_Content => array($modifiedContentId),
425  self::TABLE_Hotel => array($modifiedHotelId),
426  )
427  );
428  }
429 
433  public function modifyParentAndAddHotelChild() {
434  $this->actionService->modifyRecords(
435  self::VALUE_PageId,
436  array(
437  self::TABLE_Content => array('uid' => self::VALUE_ContentIdLast, self::FIELD_ContentHotel => '5,__nextUid'),
438  self::TABLE_Hotel => array('uid' => '__NEW', 'title' => 'Hotel #2'),
439  )
440  );
441  }
442 
447  $this->actionService->modifyRecord(
448  self::TABLE_Content,
449  self::VALUE_ContentIdFirst,
450  array(self::FIELD_ContentHotel => '3'),
451  array(self::TABLE_Hotel => array(4))
452  );
453  }
454 
459  $this->actionService->modifyRecords(
460  self::VALUE_PageId,
461  array(
462  self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'header' => 'Testing #1', self::FIELD_ContentHotel => '3,4'),
463  self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
464  )
465  );
466  $this->recordIds['versionedContentId'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
467  $this->recordIds['versionedHotelIdFirst'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Hotel, 3);
468  $this->recordIds['versionedHotelIdSecond'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Hotel, 4);
469  $this->actionService->clearWorkspaceRecords(
470  array(
471  self::TABLE_Content => array($this->recordIds['versionedContentId']),
472  self::TABLE_Hotel => array($this->recordIds['versionedHotelIdSecond']),
473  )
474  );
475  $this->actionService->modifyRecords(
476  self::VALUE_PageId,
477  array(
478  self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'header' => 'Testing #2', self::FIELD_ContentHotel => '3,4'),
479  self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #2'),
480  )
481  );
482  }
483 
484 }
setUpFrontendRootPage($pageId, array $typoScriptFiles=array())
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]