2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\IRRE\ForeignField
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Core\Utility\StringUtility
;
20 * Functional test for the DataHandler
22 abstract class AbstractActionTestCase
extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
24 const VALUE_PageId
= 89;
25 const VALUE_PageIdTarget
= 90;
26 const VALUE_PageIdWebsite
= 1;
27 const VALUE_ContentIdFirst
= 297;
28 const VALUE_ContentIdLast
= 298;
29 const VALUE_HotelIdFirst
= 3;
30 const VALUE_HotelIdSecond
= 4;
31 const VALUE_HotelIdThird
= 5;
32 const VALUE_LanguageId
= 1;
33 const VALUE_LanguageIdSecond
= 2;
35 const TABLE_Page
= 'pages';
36 const TABLE_PageOverlay
= 'pages_language_overlay';
37 const TABLE_Content
= 'tt_content';
38 const TABLE_Hotel
= 'tx_irretutorial_1nff_hotel';
39 const TABLE_Offer
= 'tx_irretutorial_1nff_offer';
40 const TABLE_Price
= 'tx_irretutorial_1nff_price';
42 const FIELD_PageHotel
= 'tx_irretutorial_hotels';
43 const FIELD_ContentHotel
= 'tx_irretutorial_1nff_hotels';
44 const FIELD_HotelOffer
= 'offers';
45 const FIELD_OfferPrice
= 'prices';
50 protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/IRRE/ForeignField/DataSet/';
52 protected function setUp()
55 $this->importScenarioDataSet('LiveDefaultPages');
56 $this->importScenarioDataSet('LiveDefaultElements');
58 $this->setUpFrontendRootPage(
61 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
62 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/ExtbaseJsonRenderer.ts',
65 $this->backendUser
->workspace
= 0;
69 * Parent content records
73 * @see DataSet/createParentContentRecord.csv
75 public function createParentContent()
77 $newTableIds = $this->actionService
->createNewRecord(self
::TABLE_Content
, self
::VALUE_PageId
, ['header' => 'Testing #1']);
78 $this->recordIds
['newContentId'] = $newTableIds[self
::TABLE_Content
][0];
82 * @see DataSet/modifyParentContentRecord.csv
84 public function modifyParentContent()
86 $this->actionService
->modifyRecord(self
::TABLE_Content
, self
::VALUE_ContentIdLast
, ['header' => 'Testing #1']);
90 * @see DataSet/deleteParentContentRecord.csv
92 public function deleteParentContent()
94 $this->actionService
->deleteRecord(self
::TABLE_Content
, self
::VALUE_ContentIdLast
);
98 * @see DataSet/copyParentContentRecord.csv
100 public function copyParentContent()
102 $newTableIds = $this->actionService
->copyRecord(self
::TABLE_Content
, self
::VALUE_ContentIdLast
, self
::VALUE_PageId
);
103 $this->recordIds
['newContentId'] = $newTableIds[self
::TABLE_Content
][self
::VALUE_ContentIdLast
];
107 * @see DataSet/copyParentContentToDifferentPage.csv
109 public function copyParentContentToDifferentPage()
111 $newTableIds = $this->actionService
->copyRecord(self
::TABLE_Content
, self
::VALUE_ContentIdLast
, self
::VALUE_PageIdTarget
);
112 $this->recordIds
['newContentId'] = $newTableIds[self
::TABLE_Content
][self
::VALUE_ContentIdLast
];
116 * @see DataSet/localizeParentContentSynchronization.csv
118 public function localizeParentContentWithLanguageSynchronization()
120 $GLOBALS['TCA'][self
::TABLE_Content
]['columns'][self
::FIELD_ContentHotel
]['config']['behaviour']['allowLanguageSynchronization'] = true;
121 $GLOBALS['TCA'][self
::TABLE_Hotel
]['columns'][self
::FIELD_HotelOffer
]['config']['behaviour']['allowLanguageSynchronization'] = true;
122 $GLOBALS['TCA'][self
::TABLE_Offer
]['columns'][self
::FIELD_OfferPrice
]['config']['behaviour']['allowLanguageSynchronization'] = true;
123 $newTableIds = $this->actionService
->localizeRecord(self
::TABLE_Content
, self
::VALUE_ContentIdLast
, self
::VALUE_LanguageId
);
124 $this->recordIds
['localizedContentId'] = $newTableIds[self
::TABLE_Content
][self
::VALUE_ContentIdLast
];
128 * @see DataSet/localizeParentContentWAllChildrenSelect.csv
130 public function localizeParentContentChainLanguageSynchronizationSource()
132 $GLOBALS['TCA'][self
::TABLE_Content
]['columns'][self
::FIELD_ContentHotel
]['config']['behaviour']['allowLanguageSynchronization'] = true;
133 $newTableIds = $this->actionService
->localizeRecord(self
::TABLE_Content
, self
::VALUE_ContentIdLast
, self
::VALUE_LanguageId
);
134 $this->recordIds
['localizedContentIdFirst'] = $newTableIds[self
::TABLE_Content
][self
::VALUE_ContentIdLast
];
135 $newTableIds = $this->actionService
->localizeRecord(self
::TABLE_Content
, $this->recordIds
['localizedContentIdFirst'], self
::VALUE_LanguageIdSecond
);
136 $this->recordIds
['localizedContentIdSecond'] = $newTableIds[self
::TABLE_Content
][$this->recordIds
['localizedContentIdFirst']];
137 $this->actionService
->modifyRecord(
139 $this->recordIds
['localizedContentIdSecond'],
140 ['l10n_state' => [self
::FIELD_ContentHotel
=> 'source']]
142 $this->actionService
->modifyRecords(
145 self
::TABLE_Content
=> ['uid' => self
::VALUE_ContentIdLast
, self
::FIELD_ContentHotel
=> '5,__nextUid'],
146 self
::TABLE_Hotel
=> ['uid' => '__NEW', 'title' => 'Hotel #2'],
152 * @see DataSet/copyParentContentToLanguageWAllChildren.csv
154 public function copyParentContentToLanguageWithAllChildren()
156 $newTableIds = $this->actionService
->copyRecordToLanguage(self
::TABLE_Content
, self
::VALUE_ContentIdLast
, self
::VALUE_LanguageId
);
157 $this->recordIds
['localizedContentId'] = $newTableIds[self
::TABLE_Content
][self
::VALUE_ContentIdLast
];
161 * @see DataSet/localizeParentContentWAllChildren.csv
163 public function localizeParentContentWithAllChildren()
165 $newTableIds = $this->actionService
->localizeRecord(self
::TABLE_Content
, self
::VALUE_ContentIdLast
, self
::VALUE_LanguageId
);
166 $this->recordIds
['localizedContentId'] = $newTableIds[self
::TABLE_Content
][self
::VALUE_ContentIdLast
];
170 * @see DataSet/Modify/localizeParentContentNCreateNestedChildrenWLanguageSynchronization.csv
172 public function localizeParentContentAndCreateNestedChildrenWithLanguageSynchronization()
174 $GLOBALS['TCA'][self
::TABLE_Content
]['columns'][self
::FIELD_ContentHotel
]['config']['behaviour']['allowLanguageSynchronization'] = true;
175 $GLOBALS['TCA'][self
::TABLE_Hotel
]['columns'][self
::FIELD_HotelOffer
]['config']['behaviour']['allowLanguageSynchronization'] = true;
176 $GLOBALS['TCA'][self
::TABLE_Offer
]['columns'][self
::FIELD_OfferPrice
]['config']['behaviour']['allowLanguageSynchronization'] = true;
178 $newTableIds = $this->actionService
->localizeRecord(self
::TABLE_Content
, self
::VALUE_ContentIdLast
, self
::VALUE_LanguageId
);
179 $this->recordIds
['localizedContentIdFirst'] = $newTableIds[self
::TABLE_Content
][self
::VALUE_ContentIdLast
];
181 $newHotelId = StringUtility
::getUniqueId('NEW');
182 $newOfferId = StringUtility
::getUniqueId('NEW');
183 $newPriceId = StringUtility
::getUniqueId('NEW');
185 self
::TABLE_Content
=> [
186 self
::VALUE_ContentIdLast
=> [self
::FIELD_ContentHotel
=> '5,' . $newHotelId],
188 self
::TABLE_Hotel
=> [
189 $newHotelId => ['pid' => self
::VALUE_PageId
, 'title' => 'New Hotel #1', 'offers' => $newOfferId],
191 self
::TABLE_Offer
=> [
192 $newOfferId => ['pid' => self
::VALUE_PageId
, 'title' => 'New Offer #1.1', 'prices' => $newPriceId],
194 self
::TABLE_Price
=> [
195 $newPriceId => ['pid' => self
::VALUE_PageId
, 'title' => 'New Price #1.1.1'],
198 $this->actionService
->invoke($dataMap, []);
199 $this->recordIds
['newHoteId'] = $this->actionService
->getDataHandler()->substNEWwithIDs
[$newHotelId];
200 $this->recordIds
['newOfferId'] = $this->actionService
->getDataHandler()->substNEWwithIDs
[$newOfferId];
201 $this->recordIds
['newPriceId'] = $this->actionService
->getDataHandler()->substNEWwithIDs
[$newPriceId];
205 * @see DataSet/changeParentContentRecordSorting.csv
207 public function changeParentContentSorting()
209 $this->actionService
->moveRecord(self
::TABLE_Content
, self
::VALUE_ContentIdFirst
, -self
::VALUE_ContentIdLast
);
213 * @see DataSet/moveParentContentRecordToDifferentPage.csv
215 public function moveParentContentToDifferentPage()
217 $this->actionService
->moveRecord(self
::TABLE_Content
, self
::VALUE_ContentIdLast
, self
::VALUE_PageIdTarget
);
221 * @see DataSet/moveParentContentRecordToDifferentPageAndChangeSorting.csv
223 public function moveParentContentToDifferentPageAndChangeSorting()
225 $this->actionService
->moveRecord(self
::TABLE_Content
, self
::VALUE_ContentIdLast
, self
::VALUE_PageIdTarget
);
226 $this->actionService
->moveRecord(self
::TABLE_Content
, self
::VALUE_ContentIdFirst
, -self
::VALUE_ContentIdLast
);
234 * @see DataSet/modifyPageRecord.csv
236 public function modifyPage()
238 $this->actionService
->modifyRecord(self
::TABLE_Page
, self
::VALUE_PageId
, ['title' => 'Testing #1']);
242 * @see DataSet/deletePageRecord.csv
244 public function deletePage()
246 $this->actionService
->deleteRecord(self
::TABLE_Page
, self
::VALUE_PageId
);
250 * @see DataSet/copyPageRecord.csv
252 public function copyPage()
254 $newTableIds = $this->actionService
->copyRecord(self
::TABLE_Page
, self
::VALUE_PageId
, self
::VALUE_PageIdTarget
);
255 $this->recordIds
['newPageId'] = $newTableIds[self
::TABLE_Page
][self
::VALUE_PageId
];
256 $this->recordIds
['newContentIdFirst'] = $newTableIds[self
::TABLE_Content
][self
::VALUE_ContentIdFirst
];
257 $this->recordIds
['newContentIdLast'] = $newTableIds[self
::TABLE_Content
][self
::VALUE_ContentIdLast
];
261 * @see DataSet/copyPageWHotelBeforeParentContent.csv
263 public function copyPageWithHotelBeforeParentContent()
265 // Ensure hotels get processed first
266 $GLOBALS['TCA'] = array_merge(
267 [self
::TABLE_Hotel
=> $GLOBALS['TCA'][self
::TABLE_Hotel
]],
271 $newTableIds = $this->actionService
->copyRecord(self
::TABLE_Page
, self
::VALUE_PageId
, self
::VALUE_PageIdTarget
);
272 $this->recordIds
['newPageId'] = $newTableIds[self
::TABLE_Page
][self
::VALUE_PageId
];
273 $this->recordIds
['newContentIdFirst'] = $newTableIds[self
::TABLE_Content
][self
::VALUE_ContentIdFirst
];
274 $this->recordIds
['newContentIdLast'] = $newTableIds[self
::TABLE_Content
][self
::VALUE_ContentIdLast
];
282 * @see DataSet/createParentContentRecordWithHotelAndOfferChildRecords.csv
284 public function createParentContentWithHotelAndOfferChildren()
286 $newTableIds = $this->actionService
->createNewRecords(
289 self
::TABLE_Content
=> ['header' => 'Testing #1', self
::FIELD_ContentHotel
=> '__nextUid'],
290 self
::TABLE_Hotel
=> ['title' => 'Hotel #1', self
::FIELD_HotelOffer
=> '__nextUid'],
291 self
::TABLE_Offer
=> ['title' => 'Offer #1'],
294 $this->recordIds
['newContentId'] = $newTableIds[self
::TABLE_Content
][0];
298 * @see DataSet/createAndCopyParentContentRecordWithHotelAndOfferChildRecords.csv
300 public function createAndCopyParentContentWithHotelAndOfferChildren()
302 $newTableIds = $this->actionService
->createNewRecords(
305 self
::TABLE_Content
=> ['header' => 'Testing #1', self
::FIELD_ContentHotel
=> '__nextUid'],
306 self
::TABLE_Hotel
=> ['title' => 'Hotel #1', self
::FIELD_HotelOffer
=> '__nextUid'],
307 self
::TABLE_Offer
=> ['title' => 'Offer #1'],
310 $this->recordIds
['newContentId'] = $newTableIds[self
::TABLE_Content
][0];
311 $this->recordIds
['newHotelId'] = $newTableIds[self
::TABLE_Hotel
][0];
312 $copiedTableIds = $this->actionService
->copyRecord(self
::TABLE_Content
, $this->recordIds
['newContentId'], self
::VALUE_PageId
);
313 $this->recordIds
['copiedContentId'] = $copiedTableIds[self
::TABLE_Content
][$this->recordIds
['newContentId']];
314 $this->recordIds
['copiedHotelId'] = $copiedTableIds[self
::TABLE_Hotel
][$this->recordIds
['newHotelId']];
318 * @see DataSet/createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords.csv
320 public function createAndLocalizeParentContentWithHotelAndOfferChildren()
322 $newTableIds = $this->actionService
->createNewRecords(
325 self
::TABLE_Content
=> ['header' => 'Testing #1', self
::FIELD_ContentHotel
=> '__nextUid'],
326 self
::TABLE_Hotel
=> ['title' => 'Hotel #1', self
::FIELD_HotelOffer
=> '__nextUid'],
327 self
::TABLE_Offer
=> ['title' => 'Offer #1'],
330 $this->recordIds
['newContentId'] = $newTableIds[self
::TABLE_Content
][0];
331 $this->recordIds
['newHotelId'] = $newTableIds[self
::TABLE_Hotel
][0];
332 $localizedTableIds = $this->actionService
->localizeRecord(self
::TABLE_Content
, $this->recordIds
['newContentId'], self
::VALUE_LanguageId
);
333 $this->recordIds
['localizedContentId'] = $localizedTableIds[self
::TABLE_Content
][$this->recordIds
['newContentId']];
337 * @see DataSet/createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords.csv
339 public function createAndLocalizeParentContentWithHotelAndOfferChildrenWithoutSortByConfiguration()
341 unset($GLOBALS['TCA'][self
::TABLE_Hotel
]['ctrl']['sortby']);
342 $newTableIds = $this->actionService
->createNewRecords(
345 self
::TABLE_Content
=> ['header' => 'Testing #1', self
::FIELD_ContentHotel
=> '__nextUid'],
346 self
::TABLE_Hotel
=> ['title' => 'Hotel #1', self
::FIELD_HotelOffer
=> '__nextUid'],
347 self
::TABLE_Offer
=> ['title' => 'Offer #1'],
350 $this->recordIds
['newContentId'] = $newTableIds[self
::TABLE_Content
][0];
351 $this->recordIds
['newHotelId'] = $newTableIds[self
::TABLE_Hotel
][0];
352 $localizedTableIds = $this->actionService
->localizeRecord(self
::TABLE_Content
, $this->recordIds
['newContentId'], self
::VALUE_LanguageId
);
353 $this->recordIds
['localizedContentId'] = $localizedTableIds[self
::TABLE_Content
][$this->recordIds
['newContentId']];
357 * @see DataSet/modifyOnlyHotelChildRecord.csv
359 public function modifyOnlyHotelChild()
361 $this->actionService
->modifyRecord(self
::TABLE_Hotel
, 4, ['title' => 'Testing #1']);
365 * @see DataSet/modifyParentRecordAndChangeHotelChildRecordsSorting.csv
367 public function modifyParentAndChangeHotelChildrenSorting()
369 $this->actionService
->modifyRecord(self
::TABLE_Content
, self
::VALUE_ContentIdFirst
, [self
::FIELD_ContentHotel
=> '4,3']);
373 * @see DataSet/modifyParentRecordWithHotelChildRecord.csv
375 public function modifyParentWithHotelChild()
377 $this->actionService
->modifyRecords(
380 self
::TABLE_Content
=> ['uid' => self
::VALUE_ContentIdFirst
, self
::FIELD_ContentHotel
=> '3,4'],
381 self
::TABLE_Hotel
=> ['uid' => 4, 'title' => 'Testing #1'],
387 * @see DataSet/modifyParentRecordAndAddHotelChildRecord.csv
389 public function modifyParentAndAddHotelChild()
391 $this->actionService
->modifyRecords(
394 self
::TABLE_Content
=> ['uid' => self
::VALUE_ContentIdLast
, self
::FIELD_ContentHotel
=> '5,__nextUid'],
395 self
::TABLE_Hotel
=> ['uid' => '__NEW', 'title' => 'Hotel #2'],
401 * @see DataSet/modifyParentRecordAndDeleteHotelChildRecord.csv
403 public function modifyParentAndDeleteHotelChild()
405 $this->actionService
->modifyRecord(
407 self
::VALUE_ContentIdFirst
,
408 [self
::FIELD_ContentHotel
=> '3'],
409 [self
::TABLE_Hotel
=> [4]]
413 public function localizePageWithLocalizationExclude()
415 $GLOBALS['TCA'][self
::TABLE_Page
]['columns'][self
::FIELD_PageHotel
]['l10n_mode'] = 'exclude';
416 $GLOBALS['TCA'][self
::TABLE_PageOverlay
]['columns'][self
::FIELD_PageHotel
]['l10n_mode'] = 'exclude';
417 $localizedTableIds = $this->actionService
->localizeRecord(self
::TABLE_Page
, self
::VALUE_PageId
, self
::VALUE_LanguageId
);
418 $this->recordIds
['localizedPageId'] = $localizedTableIds[self
::TABLE_Page
][self
::VALUE_PageId
];
419 $this->recordIds
['localizedPageOverlayId'] = $localizedTableIds[self
::TABLE_PageOverlay
][self
::VALUE_PageId
];
422 public function localizePageAndAddHotelChildWithLocalizationExclude()
424 $GLOBALS['TCA'][self
::TABLE_Page
]['columns'][self
::FIELD_PageHotel
]['l10n_mode'] = 'exclude';
425 $GLOBALS['TCA'][self
::TABLE_PageOverlay
]['columns'][self
::FIELD_PageHotel
]['l10n_mode'] = 'exclude';
426 $localizedTableIds = $this->actionService
->localizeRecord(self
::TABLE_Page
, self
::VALUE_PageId
, self
::VALUE_LanguageId
);
427 $this->recordIds
['localizedPageId'] = $localizedTableIds[self
::TABLE_Page
][self
::VALUE_PageId
];
428 $this->recordIds
['localizedPageOverlayId'] = $localizedTableIds[self
::TABLE_PageOverlay
][self
::VALUE_PageId
];
429 $this->actionService
->modifyRecords(
432 self
::TABLE_Page
=> ['uid' => self
::VALUE_PageId
, self
::FIELD_PageHotel
=> '2,__nextUid'],
433 self
::TABLE_Hotel
=> ['uid' => '__NEW', 'title' => 'Hotel #007'],
438 public function localizePageWithLanguageSynchronization()
440 $GLOBALS['TCA'][self
::TABLE_PageOverlay
]['columns'][self
::FIELD_PageHotel
]['config']['behaviour']['allowLanguageSynchronization'] = true;
441 $localizedTableIds = $this->actionService
->localizeRecord(self
::TABLE_Page
, self
::VALUE_PageId
, self
::VALUE_LanguageId
);
442 $this->recordIds
['localizedPageId'] = $localizedTableIds[self
::TABLE_Page
][self
::VALUE_PageId
];
443 $this->recordIds
['localizedPageOverlayId'] = $localizedTableIds[self
::TABLE_PageOverlay
][self
::VALUE_PageId
];
446 public function localizePageAndAddHotelChildWithLanguageSynchronization()
448 $GLOBALS['TCA'][self
::TABLE_PageOverlay
]['columns'][self
::FIELD_PageHotel
]['config']['behaviour']['allowLanguageSynchronization'] = true;
449 $localizedTableIds = $this->actionService
->localizeRecord(self
::TABLE_Page
, self
::VALUE_PageId
, self
::VALUE_LanguageId
);
450 $this->recordIds
['localizedPageId'] = $localizedTableIds[self
::TABLE_Page
][self
::VALUE_PageId
];
451 $this->recordIds
['localizedPageOverlayId'] = $localizedTableIds[self
::TABLE_PageOverlay
][self
::VALUE_PageId
];
452 $this->actionService
->modifyRecords(
455 self
::TABLE_Page
=> ['uid' => self
::VALUE_PageId
, self
::FIELD_PageHotel
=> '2,__nextUid'],
456 self
::TABLE_Hotel
=> ['uid' => '__NEW', 'title' => 'Hotel #007'],
461 public function localizePageAndAddMonoglotHotelChildWithLanguageSynchronization()
463 unset($GLOBALS['TCA'][self
::TABLE_Hotel
]['ctrl']['languageField']);
464 unset($GLOBALS['TCA'][self
::TABLE_Hotel
]['ctrl']['transOrigPointerField']);
465 $GLOBALS['TCA'][self
::TABLE_PageOverlay
]['columns'][self
::FIELD_PageHotel
]['config']['behaviour']['allowLanguageSynchronization'] = true;
466 $localizedTableIds = $this->actionService
->localizeRecord(self
::TABLE_Page
, self
::VALUE_PageId
, self
::VALUE_LanguageId
);
467 $this->recordIds
['localizedPageId'] = $localizedTableIds[self
::TABLE_Page
][self
::VALUE_PageId
];
468 $this->recordIds
['localizedPageOverlayId'] = $localizedTableIds[self
::TABLE_PageOverlay
][self
::VALUE_PageId
];
469 $this->actionService
->modifyRecords(
472 self
::TABLE_Page
=> ['uid' => self
::VALUE_PageId
, self
::FIELD_PageHotel
=> '2,__nextUid'],
473 self
::TABLE_Hotel
=> ['uid' => '__NEW', 'title' => 'Hotel #007'],
478 public function localizeAndCopyPageWithLanguageSynchronization()
480 $GLOBALS['TCA'][self
::TABLE_PageOverlay
]['columns'][self
::FIELD_PageHotel
]['config']['behaviour']['allowLanguageSynchronization'] = true;
481 $localizedTableIds = $this->actionService
->localizeRecord(self
::TABLE_Page
, self
::VALUE_PageId
, self
::VALUE_LanguageId
);
482 $this->recordIds
['localizedPageId'] = $localizedTableIds[self
::TABLE_Page
][self
::VALUE_PageId
];
483 $this->recordIds
['localizedPageOverlayId'] = $localizedTableIds[self
::TABLE_PageOverlay
][self
::VALUE_PageId
];
484 $newTableIds = $this->actionService
->copyRecord(self
::TABLE_Page
, self
::VALUE_PageId
, self
::VALUE_PageIdTarget
);
485 $this->recordIds
['newPageId'] = $newTableIds[self
::TABLE_Page
][self
::VALUE_PageId
];