[TASK] Extend DataHandler IRRE functional tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / IRRE / CSV / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\IRRE\CSV;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2014 Oliver Hader <oliver.hader@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 require_once __DIR__ . '/../../../../../../core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php';
28
29 /**
30 * Functional test for the DataHandler
31 */
32 abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase {
33
34 const VALUE_PageId = 89;
35 const VALUE_PageIdTarget = 90;
36 const VALUE_PageIdWebsite = 1;
37 const VALUE_ContentIdFirst = 297;
38 const VALUE_ContentIdLast = 298;
39 const VALUE_HotelIdFirst = 3;
40 const VALUE_HotelIdSecond = 4;
41 const VALUE_HotelIdThird = 5;
42 const VALUE_LanguageId = 1;
43 const VALUE_WorkspaceId = 1;
44
45 const TABLE_Page = 'pages';
46 const TABLE_Content = 'tt_content';
47 const TABLE_Hotel = 'tx_irretutorial_1ncsv_hotel';
48 const TABLE_Offer = 'tx_irretutorial_1ncsv_offer';
49
50 const FIELD_ContentHotel = 'tx_irretutorial_1ncsv_hotels';
51 const FIELD_HotelOffer = 'offers';
52
53 /**
54 * @var string
55 */
56 protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/IRRE/CSV/DataSet/';
57
58 /**
59 * @var array
60 */
61 protected $coreExtensionsToLoad = array(
62 'fluid',
63 'version',
64 'workspaces',
65 );
66
67 public function setUp() {
68 parent::setUp();
69 $this->importScenarioDataSet('LiveDefaultPages');
70 $this->importScenarioDataSet('LiveDefaultElements');
71 $this->importScenarioDataSet('ReferenceIndex');
72
73 $this->setUpFrontendRootPage(1, array('typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts'));
74 $this->backendUser->workspace = self::VALUE_WorkspaceId;
75 }
76
77 /**
78 * Parent content records
79 */
80
81 /**
82 * @see DataSet/Assertion/createParentContentRecord.csv
83 */
84 public function createParentContent() {
85 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
86 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
87 }
88
89 /**
90 * @see DataSet/Assertion/modifyParentContentRecord.csv
91 */
92 public function modifyParentContent() {
93 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, array('header' => 'Testing #1'));
94 }
95
96 /**
97 * @see DataSet/Assertion/deleteParentContentRecord.csv
98 */
99 public function deleteParentContent() {
100 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
101 }
102
103 /**
104 * @see DataSet/Assertion/deleteParentContentRecordAndDiscardDeletedParentRecord.csv
105 */
106 public function deleteParentContentAndDiscardDeletedParent() {
107 $newTableIds = $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
108 $versionedDeletedContentId = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
109 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedDeletedContentId);
110 }
111
112 /**
113 * @see DataSet/Assertion/copyParentContentRecord.csv
114 */
115 public function copyParentContent() {
116 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
117 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
118 }
119
120 /**
121 * @see DataSet/copyParentContentToDifferentPage.csv
122 */
123 public function copyParentContentToDifferentPage() {
124 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
125 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
126 }
127
128 /**
129 * @see DataSet/Assertion/localizeParentContentRecord.csv
130 */
131 public function localizeParentContent() {
132 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
133 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
134 }
135
136 /**
137 * @see DataSet/Assertion/changeParentContentRecordSorting.csv
138 */
139 public function changeParentContentSorting() {
140 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
141 }
142
143 /**
144 * @see DataSet/Assertion/moveParentContentRecordToDifferentPage.csv
145 */
146 public function moveParentContentToDifferentPage() {
147 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
148 }
149
150 /**
151 * @see DataSet/Assertion/moveParentContentRecordToDifferentPageAndChangeSorting.csv
152 */
153 public function moveParentContentToDifferentPageAndChangeSorting() {
154 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
155 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
156 }
157
158 /**
159 * Page records
160 */
161
162 /**
163 * @see DataSet/Assertion/modifyPageRecord.csv
164 */
165 public function modifyPage() {
166 $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1'));
167 }
168
169 /**
170 * @see DataSet/Assertion/deletePageRecord.csv
171 */
172 public function deletePage() {
173 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
174 }
175
176 /**
177 * @see DataSet/Assertion/copyPageRecord.csv
178 */
179 public function copyPage() {
180 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
181 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
182 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
183 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
184 }
185
186 /**
187 * @test
188 * @see DataSet/Assertion/copyPageWHotelBeforeParentContent.csv
189 */
190 public function copyPageWithHotelBeforeParentContent() {
191 // Ensure hotels get processed first
192 $GLOBALS['TCA'] = array_merge(
193 array(self::TABLE_Hotel => $GLOBALS['TCA'][self::TABLE_Hotel]),
194 $GLOBALS['TCA']
195 );
196
197 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
198 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
199 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
200 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
201 }
202
203 /**
204 * IRRE Child Records
205 */
206
207 /**
208 * @see DataSet/Assertion/createParentContentRecordWithHotelAndOfferChildRecords.csv
209 */
210 public function createParentContentWithHotelAndOfferChildren() {
211 $newTableIds = $this->actionService->createNewRecords(
212 self::VALUE_PageId,
213 array(
214 self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
215 self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
216 self::TABLE_Offer => array('title' => 'Offer #1'),
217 )
218 );
219 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
220 }
221
222 /**
223 * @see DataSet/Assertion/createAndCopyParentContentRecordWithHotelAndOfferChildRecords.csv
224 */
225 public function createAndCopyParentContentWithHotelAndOfferChildren() {
226 // @todo Copying the new child records is broken in the Core
227 $newTableIds = $this->actionService->createNewRecords(
228 self::VALUE_PageId,
229 array(
230 self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
231 self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
232 self::TABLE_Offer => array('title' => 'Offer #1'),
233 )
234 );
235 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
236 $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
237 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
238 $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
239 $this->recordIds['copiedHotelId'] = $copiedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
240 }
241
242 /**
243 * @see DataSet/Assertion/createAndCopyParentContentRecordWithHotelAndOfferChildRecordsAndDiscardCopiedParentRecord.csv
244 */
245 public function createAndCopyParentContentWithHotelAndOfferChildrenAndDiscardCopiedParent() {
246 // @todo Copying the new child records is broken in the Core
247 $newTableIds = $this->actionService->createNewRecords(
248 self::VALUE_PageId,
249 array(
250 self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
251 self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
252 self::TABLE_Offer => array('title' => 'Offer #1'),
253 )
254 );
255 $this->recordIds['newContentId'] = $newTableIds['tt_content'][0];
256 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
257 $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
258 $versionedCopiedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, $this->recordIds['copiedContentId']);
259 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId);
260 }
261
262 /**
263 * @see DataSet/Assertion/createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords.csv
264 */
265 public function createAndLocalizeParentContentWithHotelAndOfferChildren() {
266 // @todo Localizing the new child records is broken in the Core
267 $newTableIds = $this->actionService->createNewRecords(
268 self::VALUE_PageId,
269 array(
270 self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
271 self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
272 self::TABLE_Offer => array('title' => 'Offer #1'),
273 )
274 );
275 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
276 $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
277 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
278 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
279 $this->recordIds['localizedHotelId'] = $localizedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
280 }
281
282 /**
283 * @see DataSet/Assertion/createNLocalizeParentContentNHotelNOfferChildrenNDiscardCreatedParent.csv
284 */
285 public function createAndLocalizeParentContentWithHotelAndOfferChildrenAndDiscardCreatedParent() {
286 $newTableIds = $this->actionService->createNewRecords(
287 self::VALUE_PageId,
288 array(
289 self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
290 self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
291 self::TABLE_Offer => array('title' => 'Offer #1'),
292 )
293 );
294 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
295 $this->recordIds['versionedNewContentId'] = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, $this->recordIds['newContentId']);
296 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
297 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
298 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $this->recordIds['versionedNewContentId']);
299 }
300
301 /**
302 * @see DataSet/Assertion/createAndLocalizeParentContentRecordWithHotelAndOfferChildRecordsAndDiscardLocalizedParentRecord.csv
303 */
304 public function createAndLocalizeParentContentWithHotelAndOfferChildrenAndDiscardLocalizedParent() {
305 // @todo Localizing the new child records is broken in the Core
306 $newTableIds = $this->actionService->createNewRecords(
307 self::VALUE_PageId,
308 array(
309 self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
310 self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
311 self::TABLE_Offer => array('title' => 'Offer #1'),
312 )
313 );
314 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
315 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
316 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
317 $versionedLocalizedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, $this->recordIds['localizedContentId']);
318 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedLocalizedContentId);
319 }
320
321 /**
322 * @see DataSet/Assertion/modifyOnlyHotelChildRecord.csv
323 */
324 public function modifyOnlyHotelChild() {
325 $this->actionService->modifyRecord(self::TABLE_Hotel, 4, array('title' => 'Testing #1'));
326 }
327
328 /**
329 * @see DataSet/Assertion/modifyParentRecordAndChangeHotelChildRecordsSorting.csv
330 */
331 public function modifyParentAndChangeHotelChildrenSorting() {
332 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array(self::FIELD_ContentHotel => '4,3'));
333 }
334
335 /**
336 * @see DataSet/Assertion/modifyParentRecordWithHotelChildRecord.csv
337 */
338 public function modifyParentWithHotelChild() {
339 $this->actionService->modifyRecords(
340 self::VALUE_PageId,
341 array(
342 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'),
343 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
344 )
345 );
346 }
347
348 /**
349 * @see DataSet/Assertion/modifyParentRecordWithHotelChildRecordAndDiscardModifiedParentRecord.csv
350 */
351 public function modifyParentWithHotelChildAndDiscardModifiedParent() {
352 $this->actionService->modifyRecords(
353 self::VALUE_PageId,
354 array(
355 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'),
356 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
357 )
358 );
359 $modifiedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
360 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $modifiedContentId);
361 }
362
363 /**
364 * @see DataSet/Assertion/modifyParentRecordWithHotelChildRecordAndDiscardAllModifiedRecords.csv
365 */
366 public function modifyParentWithHotelChildAndDiscardAll() {
367 $this->actionService->modifyRecords(
368 self::VALUE_PageId,
369 array(
370 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'),
371 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
372 )
373 );
374 $modifiedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
375 $modifiedHotelId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Hotel, 4);
376 $this->actionService->clearWorkspaceRecords(
377 array(
378 self::TABLE_Content => array($modifiedContentId),
379 self::TABLE_Hotel => array($modifiedHotelId),
380 )
381 );
382 }
383
384 /**
385 * @see DataSet/Assertion/modifyParentRecordAndAddHotelChildRecord.csv
386 */
387 public function modifyParentAndAddHotelChild() {
388 $this->actionService->modifyRecords(
389 self::VALUE_PageId,
390 array(
391 self::TABLE_Content => array('uid' => self::VALUE_ContentIdLast, self::FIELD_ContentHotel => '5,__nextUid'),
392 self::TABLE_Hotel => array('uid' => '__NEW', 'title' => 'Hotel #2'),
393 )
394 );
395 }
396
397 /**
398 * @see DataSet/Assertion/modifyParentRecordAndDeleteHotelChildRecord.csv
399 */
400 public function modifyParentAndDeleteHotelChild() {
401 $this->actionService->modifyRecord(
402 self::TABLE_Content,
403 self::VALUE_ContentIdFirst,
404 array(self::FIELD_ContentHotel => '3'),
405 array(self::TABLE_Hotel => array(4))
406 );
407 }
408
409 /**
410 * @see DataSet/modifyNDiscardNModifyParentWHotelChild.csv
411 */
412 public function modifyAndDiscardAndModifyParentWithHotelChild() {
413 $this->actionService->modifyRecords(
414 self::VALUE_PageId,
415 array(
416 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'header' => 'Testing #1', self::FIELD_ContentHotel => '3,4'),
417 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
418 )
419 );
420 $this->recordIds['versionedContentId'] = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
421 $this->recordIds['versionedHotelIdFirst'] = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Hotel, 3);
422 $this->recordIds['versionedHotelIdSecond'] = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Hotel, 4);
423 $this->actionService->clearWorkspaceRecords(
424 array(
425 self::TABLE_Content => array($this->recordIds['versionedContentId']),
426 self::TABLE_Hotel => array($this->recordIds['versionedHotelIdSecond']),
427 )
428 );
429 $this->actionService->modifyRecords(
430 self::VALUE_PageId,
431 array(
432 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'header' => 'Testing #2', self::FIELD_ContentHotel => '3,4'),
433 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #2'),
434 )
435 );
436 }
437
438 }