[BUGFIX] Unhide page translations by default
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / IRRE / CSV / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\IRRE\CSV;
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 /**
18 * Functional test for the DataHandler
19 */
20 abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
21 {
22 const VALUE_PageId = 89;
23 const VALUE_PageIdTarget = 90;
24 const VALUE_PageIdWebsite = 1;
25 const VALUE_ContentIdFirst = 297;
26 const VALUE_ContentIdLast = 298;
27 const VALUE_HotelIdFirst = 3;
28 const VALUE_HotelIdSecond = 4;
29 const VALUE_HotelIdThird = 5;
30 const VALUE_LanguageId = 1;
31 const VALUE_LanguageIdSecond = 2;
32
33 const TABLE_Page = 'pages';
34 const TABLE_Content = 'tt_content';
35 const TABLE_Hotel = 'tx_irretutorial_1ncsv_hotel';
36 const TABLE_Offer = 'tx_irretutorial_1ncsv_offer';
37
38 const FIELD_PageHotel = 'tx_irretutorial_1ncsv_hotels';
39 const FIELD_ContentHotel = 'tx_irretutorial_1ncsv_hotels';
40 const FIELD_HotelOffer = 'offers';
41
42 /**
43 * @var string
44 */
45 protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/IRRE/CSV/DataSet/';
46
47 protected function setUp()
48 {
49 parent::setUp();
50 $this->importScenarioDataSet('LiveDefaultPages');
51 $this->importScenarioDataSet('LiveDefaultElements');
52
53 $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
54 }
55
56 /**
57 * Parent content records
58 */
59
60 /**
61 * @see DataSet/createParentContentRecord.csv
62 */
63 public function createParentContent()
64 {
65 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
66 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
67 }
68
69 /**
70 * @see DataSet/modifyParentContentRecord.csv
71 */
72 public function modifyParentContent()
73 {
74 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, ['header' => 'Testing #1']);
75 }
76
77 /**
78 * @see DataSet/deleteParentContentRecord.csv
79 */
80 public function deleteParentContent()
81 {
82 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
83 }
84
85 /**
86 * @see DataSet/copyParentContentRecord.csv
87 */
88 public function copyParentContent()
89 {
90 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
91 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
92 }
93
94 /**
95 * @see DataSet/copyParentContentToDifferentPage.csv
96 */
97 public function copyParentContentToDifferentPage()
98 {
99 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
100 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
101 }
102
103 /**
104 * @see DataSet/copyParentContentToLanguage.csv
105 * Should copy all children as well
106 */
107 public function copyParentContentToLanguage()
108 {
109 $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
110 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
111 }
112 /**
113 * @see DataSet/localizeParentContentWAllChildren.csv
114 * Should localize all children as well
115 */
116 public function localizeParentContentWithAllChildren()
117 {
118 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
119 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
120 }
121
122 public function localizeParentContentWithLanguageSynchronization()
123 {
124 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
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 $this->actionService->modifyRecords(
128 self::VALUE_PageId,
129 [
130 self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, self::FIELD_ContentHotel => '5,__nextUid'],
131 self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #2'],
132 ]
133 );
134 }
135
136 /**
137 * @see DataSet/changeParentContentRecordSorting.csv
138 */
139 public function changeParentContentSorting()
140 {
141 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
142 }
143
144 /**
145 * @see DataSet/moveParentContentRecordToDifferentPage.csv
146 */
147 public function moveParentContentToDifferentPage()
148 {
149 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
150 }
151
152 /**
153 * @see DataSet/moveParentContentRecordToDifferentPageAndChangeSorting.csv
154 */
155 public function moveParentContentToDifferentPageAndChangeSorting()
156 {
157 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
158 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
159 }
160
161 /**
162 * Page records
163 */
164
165 /**
166 * @see DataSet/modifyPageRecord.csv
167 */
168 public function modifyPage()
169 {
170 $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1']);
171 }
172
173 /**
174 * @see DataSet/deletePageRecord.csv
175 */
176 public function deletePage()
177 {
178 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
179 }
180
181 /**
182 * @see DataSet/copyPageRecord.csv
183 */
184 public function copyPage()
185 {
186 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
187 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
188 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
189 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
190 }
191
192 /**
193 * @see DataSet/copyPageWHotelBeforeParentContent.csv
194 */
195 public function copyPageWithHotelBeforeParentContent()
196 {
197 // Ensure hotels get processed first
198 $GLOBALS['TCA'] = array_merge(
199 [self::TABLE_Hotel => $GLOBALS['TCA'][self::TABLE_Hotel]],
200 $GLOBALS['TCA']
201 );
202
203 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
204 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
205 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
206 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
207 }
208
209 /**
210 * IRRE Child Records
211 */
212
213 /**
214 * @see DataSet/createParentContentRecordWithHotelAndOfferChildRecords.csv
215 */
216 public function createParentContentWithHotelAndOfferChildren()
217 {
218 $newTableIds = $this->actionService->createNewRecords(
219 self::VALUE_PageId,
220 [
221 self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
222 self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
223 self::TABLE_Offer => ['title' => 'Offer #1'],
224 ]
225 );
226 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
227 }
228
229 /**
230 * @see DataSet/createAndCopyParentContentRecordWithHotelAndOfferChildRecords.csv
231 */
232 public function createAndCopyParentContentWithHotelAndOfferChildren()
233 {
234 $newTableIds = $this->actionService->createNewRecords(
235 self::VALUE_PageId,
236 [
237 self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
238 self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
239 self::TABLE_Offer => ['title' => 'Offer #1'],
240 ]
241 );
242 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
243 $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
244 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
245 $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
246 $this->recordIds['copiedHotelId'] = $copiedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
247 }
248
249 /**
250 * @see DataSet/createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords.csv
251 */
252 public function createAndLocalizeParentContentWithHotelAndOfferChildren()
253 {
254 $newTableIds = $this->actionService->createNewRecords(
255 self::VALUE_PageId,
256 [
257 self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'],
258 self::TABLE_Hotel => ['title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'],
259 self::TABLE_Offer => ['title' => 'Offer #1'],
260 ]
261 );
262 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
263 $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
264 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
265 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
266 $this->recordIds['localizedHotelId'] = $localizedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
267 }
268
269 /**
270 * @see DataSet/modifyOnlyHotelChildRecord.csv
271 */
272 public function modifyOnlyHotelChild()
273 {
274 $this->actionService->modifyRecord(self::TABLE_Hotel, 4, ['title' => 'Testing #1']);
275 }
276
277 /**
278 * @see DataSet/modifyParentRecordAndChangeHotelChildRecordsSorting.csv
279 */
280 public function modifyParentAndChangeHotelChildrenSorting()
281 {
282 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, [self::FIELD_ContentHotel => '4,3']);
283 }
284
285 /**
286 * @see DataSet/modifyParentRecordWithHotelChildRecord.csv
287 */
288 public function modifyParentWithHotelChild()
289 {
290 $this->actionService->modifyRecords(
291 self::VALUE_PageId,
292 [
293 self::TABLE_Content => ['uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'],
294 self::TABLE_Hotel => ['uid' => 4, 'title' => 'Testing #1'],
295 ]
296 );
297 }
298
299 /**
300 * @see DataSet/modifyParentRecordAndAddHotelChildRecord.csv
301 */
302 public function modifyParentAndAddHotelChild()
303 {
304 $this->actionService->modifyRecords(
305 self::VALUE_PageId,
306 [
307 self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, self::FIELD_ContentHotel => '5,__nextUid'],
308 self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #2'],
309 ]
310 );
311 }
312
313 /**
314 * @see DataSet/modifyParentRecordAndDeleteHotelChildRecord.csv
315 */
316 public function modifyParentAndDeleteHotelChild()
317 {
318 $this->actionService->modifyRecord(
319 self::TABLE_Content,
320 self::VALUE_ContentIdFirst,
321 [self::FIELD_ContentHotel => '3'],
322 [self::TABLE_Hotel => [4]]
323 );
324 }
325
326 public function localizePageWithLocalizationExclude()
327 {
328 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['l10n_mode'] = 'exclude';
329 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
330 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
331 }
332
333 public function localizePageTwiceWithLocalizationExclude()
334 {
335 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['l10n_mode'] = 'exclude';
336 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
337 $this->recordIds['localizedPageIdFirst'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
338 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageIdSecond);
339 $this->recordIds['localizedPageIdSecond'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
340 }
341
342 public function localizePageAndAddHotelChildWithLocalizationExclude()
343 {
344 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['l10n_mode'] = 'exclude';
345 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
346 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
347 $this->actionService->modifyRecords(
348 self::VALUE_PageId,
349 [
350 self::TABLE_Page => ['uid' => self::VALUE_PageId, self::FIELD_PageHotel => '2,__nextUid'],
351 self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #007'],
352 ]
353 );
354 }
355
356 public function localizePageWithLanguageSynchronization()
357 {
358 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
359 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
360 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
361 }
362
363 public function localizePageAndAddHotelChildWithLanguageSynchronization()
364 {
365 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
366 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
367 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
368 $this->actionService->modifyRecords(
369 self::VALUE_PageId,
370 [
371 self::TABLE_Page => ['uid' => self::VALUE_PageId, self::FIELD_PageHotel => '2,__nextUid'],
372 self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #007'],
373 ]
374 );
375 }
376
377 public function localizePageAndAddMonoglotHotelChildWithLanguageSynchronization()
378 {
379 unset($GLOBALS['TCA'][self::TABLE_Hotel]['ctrl']['languageField']);
380 unset($GLOBALS['TCA'][self::TABLE_Hotel]['ctrl']['transOrigPointerField']);
381 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
382 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
383 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
384 $this->actionService->modifyRecords(
385 self::VALUE_PageId,
386 [
387 self::TABLE_Page => ['uid' => self::VALUE_PageId, self::FIELD_PageHotel => '2,__nextUid'],
388 self::TABLE_Hotel => ['uid' => '__NEW', 'title' => 'Hotel #007'],
389 ]
390 );
391 }
392
393 public function localizeAndCopyPageWithLanguageSynchronization()
394 {
395 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
396 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
397 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
398 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
399 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
400 }
401
402 public function localizePageWithSynchronizationAndCustomLocalizedHotel()
403 {
404 $GLOBALS['TCA'][self::TABLE_Page]['columns'][self::FIELD_PageHotel]['config']['behaviour']['allowLanguageSynchronization'] = true;
405 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
406 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
407 // Using "localized page ID" on purpose because BE editing uses a "page" record and data handler
408 $this->actionService->modifyRecords(
409 $this->recordIds['localizedPageId'],
410 [
411 self::TABLE_Page => ['uid' => $this->recordIds['localizedPageId'], self::FIELD_PageHotel => '6,__nextUid', 'l10n_state' => [self::FIELD_PageHotel => 'custom']],
412 self::TABLE_Hotel => ['uid' => '__NEW', 'sys_language_uid' => self::VALUE_LanguageId, 'title' => 'Hotel in dansk page only'],
413 ]
414 );
415 }
416 }