[TASK] Clean up TSFE constructor initialization
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / IRRE / ForeignField / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\IRRE\ForeignField;
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
17 use TYPO3\CMS\Core\Utility\StringUtility;
18
19 /**
20 * Functional test for the DataHandler
21 */
22 abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
23 {
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_OfferIdLast = 8;
33 const VALUE_LanguageId = 1;
34 const VALUE_LanguageIdSecond = 2;
35
36 const TABLE_Page = 'pages';
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';
41
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';
46
47 /**
48 * @var string
49 */
50 protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/IRRE/ForeignField/DataSet/';
51
52 protected function setUp(): void
53 {
54 parent::setUp();
55 $this->importScenarioDataSet('LiveDefaultPages');
56 $this->importScenarioDataSet('LiveDefaultElements');
57
58 $this->setUpFrontendSite(1, $this->siteLanguageConfiguration);
59 $this->setUpFrontendRootPage(
60 1,
61 [
62 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript',
63 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/ExtbaseJsonRenderer.typoscript',
64 ]
65 );
66 }
67
68 /**
69 * Parent content records
70 */
71
72 /**
73 * @see DataSet/createParentContentRecord.csv
74 */
75 public function createParentContent()
76 {
77 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
78 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
79 }
80
81 /**
82 * @see DataSet/modifyParentContentRecord.csv
83 */
84 public function modifyParentContent()
85 {
86 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, ['header' => 'Testing #1']);
87 }
88
89 /**
90 * @see DataSet/deleteParentContentRecord.csv
91 */
92 public function deleteParentContent()
93 {
94 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
95 }
96
97 /**
98 * @see DataSet/copyParentContentRecord.csv
99 */
100 public function copyParentContent()
101 {
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];
104 }
105
106 /**
107 * @see DataSet/copyParentContentToDifferentPage.csv
108 */
109 public function copyParentContentToDifferentPage()
110 {
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];
113 }
114
115 /**
116 * @see DataSet/localizeParentContentSynchronization.csv
117 */
118 public function localizeParentContentWithLanguageSynchronization()
119 {
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];
125 }
126
127 /**
128 * @see DataSet/localizeParentContentWAllChildrenSelect.csv
129 */
130 public function localizeParentContentChainLanguageSynchronizationSource()
131 {
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(
138 self::TABLE_Content,
139 $this->recordIds['localizedContentIdSecond'],
140 ['l10n_state' => [self::FIELD_ContentHotel => 'source']]
141 );
142 $this->actionService->modifyRecords(
143 self::VALUE_PageId,
144 [
145 self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, self::FIELD_ContentHotel => '5,__nextUid'],
146 self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #2'],
147 ]
148 );
149 }
150
151 /**
152 * @see DataSet/copyParentContentToLanguageWAllChildren.csv
153 */
154 public function copyParentContentToLanguageWithAllChildren()
155 {
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];
158 }
159
160 /**
161 * @see DataSet/localizeParentContentWAllChildren.csv
162 */
163 public function localizeParentContentWithAllChildren()
164 {
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];
167 }
168
169 /**
170 * @see DataSet/Modify/localizeParentContentNCreateNestedChildrenWLanguageSynchronization.csv
171 */
172 public function localizeParentContentAndCreateNestedChildrenWithLanguageSynchronization()
173 {
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;
177
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];
180
181 $newHotelId = StringUtility::getUniqueId('NEW');
182 $newOfferId = StringUtility::getUniqueId('NEW');
183 $newPriceId = StringUtility::getUniqueId('NEW');
184 $dataMap = [
185 self::TABLE_Content => [
186 self::VALUE_ContentIdLast => [self::FIELD_ContentHotel => '5,' . $newHotelId],
187 ],
188 self::TABLE_Hotel => [
189 $newHotelId => ['pid' => self::VALUE_PageId, 'title' => 'New Hotel #1', 'offers' => $newOfferId],
190 ],
191 self::TABLE_Offer => [
192 $newOfferId => ['pid' => self::VALUE_PageId, 'title' => 'New Offer #1.1', 'prices' => $newPriceId],
193 ],
194 self::TABLE_Price => [
195 $newPriceId => ['pid' => self::VALUE_PageId, 'title' => 'New Price #1.1.1'],
196 ],
197 ];
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];
202 }
203
204 /**
205 * @see DataSet/localizeParentContentSynchronization.csv
206 */
207 public function localizeParentContentAndSetInvalidChildReferenceWithLanguageSynchronization()
208 {
209 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
210 $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['allowLanguageSynchronization'] = true;
211 $GLOBALS['TCA'][self::TABLE_Offer]['columns'][self::FIELD_OfferPrice]['config']['behaviour']['allowLanguageSynchronization'] = true;
212 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
213 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
214 // modify IRRE relation value of localized record (which should be sanitized and filtered)
215 $this->actionService->modifyRecord(self::TABLE_Content, $this->recordIds['localizedContentId'], [self::FIELD_ContentHotel => '0']);
216 }
217
218 /**
219 * @see DataSet/localizeParentContentSynchronization.csv
220 */
221 public function localizeParentContentAndSetInvalidChildReferenceWithLateLanguageSynchronization()
222 {
223 // disable language synchronization
224 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['allowLanguageSynchronization'] = false;
225 $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['allowLanguageSynchronization'] = false;
226 $GLOBALS['TCA'][self::TABLE_Offer]['columns'][self::FIELD_OfferPrice]['config']['behaviour']['allowLanguageSynchronization'] = false;
227 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
228 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
229 $this->recordIds['localizedHotelId'] = $newTableIds[self::TABLE_Hotel][self::VALUE_HotelIdThird];
230 $this->recordIds['localizedOfferId'] = $newTableIds[self::TABLE_Offer][self::VALUE_OfferIdLast];
231 // now enable language synchronization
232 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
233 $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['allowLanguageSynchronization'] = true;
234 $GLOBALS['TCA'][self::TABLE_Offer]['columns'][self::FIELD_OfferPrice]['config']['behaviour']['allowLanguageSynchronization'] = true;
235 // modify IRRE relation values of localized records (which should be sanitized and filtered)
236 $this->actionService->modifyRecords(
237 self::VALUE_PageId,
238 [
239 self::TABLE_Content => ['uid' => $this->recordIds['localizedContentId'], self::FIELD_ContentHotel => '0'],
240 self::TABLE_Hotel => ['uid' => $this->recordIds['localizedHotelId'], self::FIELD_ContentHotel => '0'],
241 self::TABLE_Offer => ['uid' => $this->recordIds['localizedOfferId'], self::FIELD_ContentHotel => '0'],
242 ]
243 );
244 }
245
246 /**
247 * @see DataSet/changeParentContentRecordSorting.csv
248 */
249 public function changeParentContentSorting()
250 {
251 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
252 }
253
254 /**
255 * @see DataSet/moveParentContentRecordToDifferentPage.csv
256 */
257 public function moveParentContentToDifferentPage()
258 {
259 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
260 }
261
262 /**
263 * @see DataSet/moveParentContentRecordToDifferentPageAndChangeSorting.csv
264 */
265 public function moveParentContentToDifferentPageAndChangeSorting()
266 {
267 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
268 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
269 }
270
271 /**
272 * Page records
273 */
274
275 /**
276 * @see DataSet/modifyPageRecord.csv
277 */
278 public function modifyPage()
279 {
280 $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1']);
281 }
282
283 /**
284 * @see DataSet/deletePageRecord.csv
285 */
286 public function deletePage()
287 {
288 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
289 }
290
291 /**
292 * @see DataSet/copyPageRecord.csv
293 */
294 public function copyPage()
295 {
296 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
297 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
298 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
299 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
300 }
301
302 /**
303 * @see DataSet/copyPageWHotelBeforeParentContent.csv
304 */
305 public function copyPageWithHotelBeforeParentContent()
306 {
307 // Ensure hotels get processed first
308 $GLOBALS['TCA'] = array_merge(
309 [self::TABLE_Hotel => $GLOBALS['TCA'][self::TABLE_Hotel]],
310 $GLOBALS['TCA']
311 );
312
313 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
314 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
315 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
316 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
317 }
318
319 /**
320 * IRRE Child Records
321 */
322
323 /**
324 * @see DataSet/createParentContentRecordWithHotelAndOfferChildRecords.csv
325 */
326 public function createParentContentWithHotelAndOfferChildren()
327 {
328 $newTableIds = $this->actionService->createNewRecords(
329 self::VALUE_PageId,
330 [
331 self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
332 self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
333 self::TABLE_Offer => ['title' => 'Offer #1'],
334 ]
335 );
336 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
337 }
338
339 /**
340 * @see DataSet/createAndCopyParentContentRecordWithHotelAndOfferChildRecords.csv
341 */
342 public function createAndCopyParentContentWithHotelAndOfferChildren()
343 {
344 $newTableIds = $this->actionService->createNewRecords(
345 self::VALUE_PageId,
346 [
347 self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
348 self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
349 self::TABLE_Offer => ['title' => 'Offer #1'],
350 ]
351 );
352 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
353 $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
354 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
355 $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
356 $this->recordIds['copiedHotelId'] = $copiedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
357 }
358
359 /**
360 * @see DataSet/createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords.csv
361 */
362 public function createAndLocalizeParentContentWithHotelAndOfferChildren()
363 {
364 $newTableIds = $this->actionService->createNewRecords(
365 self::VALUE_PageId,
366 [
367 self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
368 self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
369 self::TABLE_Offer => ['title' => 'Offer #1'],
370 ]
371 );
372 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
373 $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
374 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
375 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
376 }
377
378 /**
379 * @see DataSet/createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords.csv
380 */
381 public function createAndLocalizeParentContentWithHotelAndOfferChildrenWithoutSortByConfiguration()
382 {
383 unset($GLOBALS['TCA'][self::TABLE_Hotel]['ctrl']['sortby']);
384 $newTableIds = $this->actionService->createNewRecords(
385 self::VALUE_PageId,
386 [
387 self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
388 self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
389 self::TABLE_Offer => ['title' => 'Offer #1'],
390 ]
391 );
392 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
393 $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
394 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
395 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
396 }
397
398 /**
399 * @see DataSet/modifyOnlyHotelChildRecord.csv
400 */
401 public function modifyOnlyHotelChild()
402 {
403 $this->actionService->modifyRecord(self::TABLE_Hotel, 4, ['title' => 'Testing #1']);
404 }
405
406 /**
407 * @see DataSet/modifyParentRecordAndChangeHotelChildRecordsSorting.csv
408 */
409 public function modifyParentAndChangeHotelChildrenSorting()
410 {
411 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, [self::FIELD_ContentHotel => '4,3']);
412 }
413
414 /**
415 * @see DataSet/modifyParentRecordWithHotelChildRecord.csv
416 */
417 public function modifyParentWithHotelChild()
418 {
419 $this->actionService->modifyRecords(
420 self::VALUE_PageId,
421 [
422 self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'],
423 self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #1'],
424 ]
425 );
426 }
427
428 /**
429 * @see DataSet/modifyParentRecordAndAddHotelChildRecord.csv
430 */
431 public function modifyParentAndAddHotelChild()
432 {
433 $this->actionService->modifyRecords(
434 self::VALUE_PageId,
435 [
436 self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, self::FIELD_ContentHotel => '5,__nextUid'],
437 self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #2'],
438 ]
439 );
440 }
441
442 /**
443 * @see DataSet/modifyParentRecordAndDeleteHotelChildRecord.csv
444 */
445 public function modifyParentAndDeleteHotelChild()
446 {
447 $this->actionService->modifyRecord(
448 self::TABLE_Content,
449 self::VALUE_ContentIdFirst,
450 [self::FIELD_ContentHotel => '3'],
451 [self::TABLE_Hotel => [4]]
452 );
453 }
454
455 public function localizePageWithLocalizationExclude()
456 {
457 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['l10n_mode'] = 'exclude';
458 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
459 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
460 }
461
462 public function localizePageTwiceWithLocalizationExclude()
463 {
464 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['l10n_mode'] = 'exclude';
465 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
466 $this->recordIds['localizedPageIdFirst'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
467 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageIdSecond);
468 $this->recordIds['localizedPageIdSecond'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
469 }
470
471 public function localizePageAndAddHotelChildWithLocalizationExclude()
472 {
473 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['l10n_mode'] = 'exclude';
474 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
475 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
476 $this->actionService->modifyRecords(
477 self::VALUE_PageId,
478 [
479 self::TABLE_Page => ['uid' => self::VALUE_PageId, self::FIELD_PageHotel => '2,__nextUid'],
480 self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #007'],
481 ]
482 );
483 }
484
485 public function localizePageWithLanguageSynchronization()
486 {
487 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
488 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
489 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
490 }
491
492 public function localizePageAndAddHotelChildWithLanguageSynchronization()
493 {
494 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
495 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
496 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
497 $this->actionService->modifyRecords(
498 self::VALUE_PageId,
499 [
500 self::TABLE_Page => ['uid' => self::VALUE_PageId, self::FIELD_PageHotel => '2,__nextUid'],
501 self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #007'],
502 ]
503 );
504 }
505
506 public function localizePageAndAddMonoglotHotelChildWithLanguageSynchronization()
507 {
508 unset($GLOBALS['TCA'][self::TABLE_Hotel]['ctrl']['languageField']);
509 unset($GLOBALS['TCA'][self::TABLE_Hotel]['ctrl']['transOrigPointerField']);
510 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
511 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
512 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
513 $this->actionService->modifyRecords(
514 self::VALUE_PageId,
515 [
516 self::TABLE_Page => ['uid' => self::VALUE_PageId, self::FIELD_PageHotel => '2,__nextUid'],
517 self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #007'],
518 ]
519 );
520 }
521
522 public function localizeAndCopyPageWithLanguageSynchronization()
523 {
524 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
525 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
526 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
527 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
528 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
529 }
530
531 public function localizePageWithSynchronizationAndCustomLocalizedHotel()
532 {
533 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
534 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
535 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
536 // Using "localized page ID" on purpose because BE editing uses a "page" record and data handler
537 $this->actionService->modifyRecords(
538 $this->recordIds['localizedPageId'],
539 [
540 self::TABLE_Page => ['uid' => $this->recordIds['localizedPageId'], self::FIELD_PageHotel => '6,__nextUid', 'l10n_state' => [self::FIELD_PageHotel => 'custom']],
541 self::TABLE_Hotel => ['uid' => '__NEW', 'sys_language_uid' => self::VALUE_LanguageId, 'title' => 'Hotel in dansk page only'],
542 ]
543 );
544 }
545 }