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_1ncsv_hotel';
38  const TABLE_Offer = 'tx_irretutorial_1ncsv_offer';
39 
40  const FIELD_ContentHotel = 'tx_irretutorial_1ncsv_hotels';
41  const FIELD_HotelOffer = 'offers';
42 
46  protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/IRRE/CSV/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(1, array('typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts'));
64  $this->backendUser->workspace = self::VALUE_WorkspaceId;
65  }
66 
74  public function createParentContent() {
75  $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
76  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
77  }
78 
82  public function modifyParentContent() {
83  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, array('header' => 'Testing #1'));
84  }
85 
89  public function deleteParentContent() {
90  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
91  }
92 
97  $newTableIds = $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
98  $versionedDeletedContentId = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
99  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedDeletedContentId);
100  }
101 
105  public function copyParentContent() {
106  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
107  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
108  }
109 
114  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
115  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
116  }
117 
122  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
123  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = FALSE;
124  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = FALSE;
125  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
126  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
127  }
128 
133  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
134  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = TRUE;
135  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = TRUE;
136  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
137  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
138  }
139 
144  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
145  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = FALSE;
146  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = FALSE;
147  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
148  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
149  }
150 
155  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
156  $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = TRUE;
157  $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = TRUE;
158  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
159  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
160  }
161 
165  public function changeParentContentSorting() {
166  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
167  }
168 
173  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
174  }
175 
180  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
181  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
182  }
183 
191  public function modifyPage() {
192  $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1'));
193  }
194 
198  public function deletePage() {
199  $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
200  }
201 
205  public function copyPage() {
206  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
207  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
208  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
209  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
210  }
211 
217  // Ensure hotels get processed first
218  $GLOBALS['TCA'] = array_merge(
219  array(self::TABLE_Hotel => $GLOBALS['TCA'][self::TABLE_Hotel]),
220  $GLOBALS['TCA']
221  );
222 
223  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
224  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
225  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
226  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
227  }
228 
237  $newTableIds = $this->actionService->createNewRecords(
238  self::VALUE_PageId,
239  array(
240  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
241  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
242  self::TABLE_Offer => array('title' => 'Offer #1'),
243  )
244  );
245  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
246  }
247 
252  // @todo Copying the new child records is broken in the Core
253  $newTableIds = $this->actionService->createNewRecords(
254  self::VALUE_PageId,
255  array(
256  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
257  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
258  self::TABLE_Offer => array('title' => 'Offer #1'),
259  )
260  );
261  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
262  $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
263  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
264  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
265  $this->recordIds['copiedHotelId'] = $copiedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
266  }
267 
272  // @todo Copying the new child records is broken in the Core
273  $newTableIds = $this->actionService->createNewRecords(
274  self::VALUE_PageId,
275  array(
276  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
277  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
278  self::TABLE_Offer => array('title' => 'Offer #1'),
279  )
280  );
281  $this->recordIds['newContentId'] = $newTableIds['tt_content'][0];
282  $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
283  $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
284  $versionedCopiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['copiedContentId']);
285  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId);
286  }
287 
292  // @todo Localizing the new child records is broken in the Core
293  $newTableIds = $this->actionService->createNewRecords(
294  self::VALUE_PageId,
295  array(
296  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
297  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
298  self::TABLE_Offer => array('title' => 'Offer #1'),
299  )
300  );
301  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
302  $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
303  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
304  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
305  $this->recordIds['localizedHotelId'] = $localizedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
306  }
307 
312  $newTableIds = $this->actionService->createNewRecords(
313  self::VALUE_PageId,
314  array(
315  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
316  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
317  self::TABLE_Offer => array('title' => 'Offer #1'),
318  )
319  );
320  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
321  $this->recordIds['versionedNewContentId'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['newContentId']);
322  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
323  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
324  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $this->recordIds['versionedNewContentId']);
325  }
326 
331  // @todo Localizing the new child records is broken in the Core
332  $newTableIds = $this->actionService->createNewRecords(
333  self::VALUE_PageId,
334  array(
335  self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
336  self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
337  self::TABLE_Offer => array('title' => 'Offer #1'),
338  )
339  );
340  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
341  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
342  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
343  $versionedLocalizedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['localizedContentId']);
344  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedLocalizedContentId);
345  }
346 
350  public function modifyOnlyHotelChild() {
351  $this->actionService->modifyRecord(self::TABLE_Hotel, 4, array('title' => 'Testing #1'));
352  }
353 
358  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array(self::FIELD_ContentHotel => '4,3'));
359  }
360 
364  public function modifyParentWithHotelChild() {
365  $this->actionService->modifyRecords(
366  self::VALUE_PageId,
367  array(
368  self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'),
369  self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
370  )
371  );
372  }
373 
378  $this->actionService->modifyRecords(
379  self::VALUE_PageId,
380  array(
381  self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'),
382  self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
383  )
384  );
385  $modifiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
386  $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $modifiedContentId);
387  }
388 
393  $this->actionService->modifyRecords(
394  self::VALUE_PageId,
395  array(
396  self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'),
397  self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
398  )
399  );
400  $modifiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
401  $modifiedHotelId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Hotel, 4);
402  $this->actionService->clearWorkspaceRecords(
403  array(
404  self::TABLE_Content => array($modifiedContentId),
405  self::TABLE_Hotel => array($modifiedHotelId),
406  )
407  );
408  }
409 
413  public function modifyParentAndAddHotelChild() {
414  $this->actionService->modifyRecords(
415  self::VALUE_PageId,
416  array(
417  self::TABLE_Content => array('uid' => self::VALUE_ContentIdLast, self::FIELD_ContentHotel => '5,__nextUid'),
418  self::TABLE_Hotel => array('uid' => '__NEW', 'title' => 'Hotel #2'),
419  )
420  );
421  }
422 
427  $this->actionService->modifyRecord(
428  self::TABLE_Content,
429  self::VALUE_ContentIdFirst,
430  array(self::FIELD_ContentHotel => '3'),
431  array(self::TABLE_Hotel => array(4))
432  );
433  }
434 
439  $this->actionService->modifyRecords(
440  self::VALUE_PageId,
441  array(
442  self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'header' => 'Testing #1', self::FIELD_ContentHotel => '3,4'),
443  self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
444  )
445  );
446  $this->recordIds['versionedContentId'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
447  $this->recordIds['versionedHotelIdFirst'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Hotel, 3);
448  $this->recordIds['versionedHotelIdSecond'] = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Hotel, 4);
449  $this->actionService->clearWorkspaceRecords(
450  array(
451  self::TABLE_Content => array($this->recordIds['versionedContentId']),
452  self::TABLE_Hotel => array($this->recordIds['versionedHotelIdSecond']),
453  )
454  );
455  $this->actionService->modifyRecords(
456  self::VALUE_PageId,
457  array(
458  self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'header' => 'Testing #2', self::FIELD_ContentHotel => '3,4'),
459  self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #2'),
460  )
461  );
462  }
463 
464 }
setUpFrontendRootPage($pageId, array $typoScriptFiles=array())
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]