de810e3f3d9a19a342d5acb0dd15a3fe60cd0e38
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / InlineRelationalRecordEditing / ForeignField / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\InlineRelationalRecordEditing\ForeignField;
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_LanguageId = 1;
40 const VALUE_WorkspaceId = 1;
41
42 const TABLE_Page = 'pages';
43 const TABLE_Content = 'tt_content';
44 const TABLE_Hotel = 'tx_irretutorial_1nff_hotel';
45 const TABLE_Offer = 'tx_irretutorial_1nff_offer';
46
47 /**
48 * @var string
49 */
50 protected $dataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/InlineRelationalRecordEditing/ForeignField/DataSet/';
51
52 /**
53 * @var array
54 */
55 protected $coreExtensionsToLoad = array(
56 'version',
57 'workspaces',
58 );
59
60 public function setUp() {
61 parent::setUp();
62 $this->importScenarioDataSet('LiveDefaultPages');
63 $this->importScenarioDataSet('LiveDefaultElements');
64
65 $this->setUpFrontendRootPage(1, array('typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts'));
66 }
67
68 /**
69 * Parent content records
70 */
71
72 /**
73 * @test
74 */
75 public function createParentContentRecord() {
76 $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
77 $this->assertAssertionDataSet('createParentContentRecord');
78
79 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
80 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
81 }
82
83 /**
84 * @test
85 */
86 public function modifyParentContentRecord() {
87 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, array('header' => 'Testing #1'));
88 $this->assertAssertionDataSet('modifyParentContentRecord');
89
90 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
91 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
92 $this->assertResponseContentStructureHasRecords(
93 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
94 self::TABLE_Hotel, 'title', array('Hotel #1')
95 );
96 }
97
98 /**
99 * @test
100 */
101 public function deleteParentContentRecord() {
102 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
103 $this->assertAssertionDataSet('deleteParentContentRecord');
104
105 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
106 $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Regular Element #2');
107 }
108
109 /**
110 * @test
111 */
112 public function deleteParentContentRecordAndDiscardDeletedParentRecord() {
113 $newTableIds = $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
114 $versionedDeletedContentId = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
115 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedDeletedContentId);
116 $this->assertAssertionDataSet('deleteParentContentRecordAndDiscardDeletedParentRecord');
117
118 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
119 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Regular Element #2');
120 }
121
122 /**
123 * @test
124 */
125 public function copyParentContentRecord() {
126 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
127 $this->assertAssertionDataSet('copyParentContentRecord');
128
129 $newContentId = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
130 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
131 $this->assertResponseContentStructureHasRecords(
132 $responseContent, self::TABLE_Content . ':' . $newContentId, 'tx_irretutorial_hotels',
133 self::TABLE_Hotel, 'title', array('Hotel #1')
134 );
135 }
136
137 /**
138 * @test
139 */
140 public function localizeParentContentRecord() {
141 $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
142 $this->assertAssertionDataSet('localizeParentContentRecord');
143
144 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
145 $this->assertResponseContentStructureHasRecords(
146 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
147 self::TABLE_Hotel, 'title', array('[Translate to Dansk:] Hotel #1')
148 );
149 }
150
151 /**
152 * @test
153 */
154 public function changeParentContentRecordSorting() {
155 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
156 $this->assertAssertionDataSet('changeParentContentRecordSorting');
157
158 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
159 $this->assertResponseContentStructureHasRecords(
160 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
161 self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2')
162 );
163 $this->assertResponseContentStructureHasRecords(
164 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
165 self::TABLE_Hotel, 'title', array('Hotel #1')
166 );
167 }
168
169 /**
170 * @test
171 */
172 public function moveParentContentRecordToDifferentPage() {
173 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
174 $this->assertAssertionDataSet('moveParentContentRecordToDifferentPage');
175
176 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
177 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Regular Element #2');
178
179 // @todo Workspace child records gets lost due to core bug
180 /*
181 $this->assertResponseContentStructureHasRecords(
182 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
183 self::TABLE_Hotel, 'title', array('Hotel #1')
184 );
185 */
186 }
187
188 /**
189 * @test
190 */
191 public function moveParentContentRecordToDifferentPageAndChangeSorting() {
192 $this->markTestSkipped('Something seems to be wrong here...');
193 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
194 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
195 $this->assertAssertionDataSet('moveParentContentRecordToDifferentPageAndChangeSorting');
196
197 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
198 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Regular Element #2', 'Regular Element #1'));
199 $this->assertResponseContentStructureHasRecords(
200 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
201 self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2')
202 );
203 $this->assertResponseContentStructureHasRecords(
204 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
205 self::TABLE_Hotel, 'title', array('Hotel #1')
206 );
207 }
208
209 /**
210 * Page records
211 */
212
213 /**
214 * @test
215 */
216 public function modifyPageRecord() {
217 $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1'));
218 $this->assertAssertionDataSet('modifyPageRecord');
219
220 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
221 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Page, 'title', 'Testing #1');
222 $this->assertResponseContentStructureHasRecords(
223 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
224 self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2')
225 );
226 }
227
228 /**
229 * @test
230 */
231 public function deletePageRecord() {
232 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
233 $this->assertAssertionDataSet('deletePageRecord');
234
235 $response = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId, FALSE);
236 $this->assertContains('RuntimeException', $response->getError());
237 }
238
239 /**
240 * @test
241 */
242 public function copyPageRecord() {
243 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
244 $this->assertAssertionDataSet('copyPageRecord');
245
246 $newPageId = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
247 $responseContent = $this->getFrontendResponse($newPageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
248 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2', 'Hotel #1'));
249 }
250
251 /**
252 * IRRE Child Records
253 */
254
255 /**
256 * @test
257 */
258 public function createParentContentRecordWithHotelAndOfferChildRecords() {
259 $newTableIds = $this->actionService->createNewRecords(
260 self::VALUE_PageId,
261 array(
262 self::TABLE_Offer => array('title' => 'Offer #1'),
263 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
264 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
265 )
266 );
267 $this->assertAssertionDataSet('createParentContentRecordWithHotelAndOfferChildRecords');
268
269 $newContentId = $newTableIds[self::TABLE_Content][0];
270 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
271 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
272
273 // @todo Shadow fields are not correct on the new placeholder
274 /*
275 $this->assertResponseContentStructureHasRecords(
276 $responseContent, self::TABLE_Content . ':' . $newContentId, 'tx_irretutorial_hotels',
277 self::TABLE_Hotel, 'title', 'Hotel #1'
278 );
279 */
280 }
281
282 /**
283 * @test
284 */
285 public function createAndCopyParentContentRecordWithHotelAndOfferChildRecords() {
286 // @todo Copying the new child records is broken in the Core
287 $newTableIds = $this->actionService->createNewRecords(
288 self::VALUE_PageId,
289 array(
290 self::TABLE_Offer => array('title' => 'Offer #1'),
291 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
292 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
293 )
294 );
295 $newContentId = $newTableIds[self::TABLE_Content][0];
296 $newHotelId = $newTableIds[self::TABLE_Hotel][0];
297 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $newContentId, self::VALUE_PageId);
298 $this->assertAssertionDataSet('createAndCopyParentContentRecordWithHotelAndOfferChildRecords');
299
300 $copiedContentId = $copiedTableIds[self::TABLE_Content][$newContentId];
301 $copiedHotelId = $copiedTableIds[self::TABLE_Hotel][$newHotelId];
302 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
303 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1 (copy 1)');
304
305 // @todo Shadow fields are not correct on the new placeholder
306 /*
307 $this->assertResponseContentStructureHasRecords(
308 $responseContent, self::TABLE_Content . ':' . $newContentId, 'tx_irretutorial_hotels',
309 self::TABLE_Hotel, 'title', 'Hotel #1'
310 );
311 $this->assertResponseContentStructureHasRecords(
312 $responseContent, self::TABLE_Content . ':' . $copiedContentId, 'tx_irretutorial_hotels',
313 self::TABLE_Hotel, 'title', 'Hotel #1'
314 );
315 $this->assertResponseContentStructureHasRecords(
316 $responseContent, self::TABLE_Hotel . ':' . $copiedHotelId, 'offers',
317 self::TABLE_Offer, 'title', 'Offer #1'
318 );
319 */
320 }
321
322 /**
323 * @test
324 */
325 public function createAndCopyParentContentRecordWithHotelAndOfferChildRecordsAndDiscardCopiedParentRecord() {
326 // @todo Copying the new child records is broken in the Core
327 $newTableIds = $this->actionService->createNewRecords(
328 self::VALUE_PageId,
329 array(
330 self::TABLE_Offer => array('title' => 'Offer #1'),
331 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
332 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
333 )
334 );
335 $newContentId = $newTableIds['tt_content'][0];
336 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $newContentId, self::VALUE_PageId);
337 $copiedContentId = $copiedTableIds[self::TABLE_Content][$newContentId];
338 $versionedCopiedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, $copiedContentId);
339 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId);
340 $this->assertAssertionDataSet('createAndCopyParentContentRecordWithHotelAndOfferChildRecordsAndDiscardCopiedParentRecord');
341
342 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
343 $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1 (copy 1)');
344 }
345
346 /**
347 * @test
348 */
349 public function createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords() {
350 // @todo Localizing the new child records is broken in the Core
351 $newTableIds = $this->actionService->createNewRecords(
352 self::VALUE_PageId,
353 array(
354 self::TABLE_Offer => array('title' => 'Offer #1'),
355 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
356 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
357 )
358 );
359 $newContentId = $newTableIds[self::TABLE_Content][0];
360 $newHotelId = $newTableIds[self::TABLE_Hotel][0];
361 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $newContentId, self::VALUE_LanguageId);
362 $this->assertAssertionDataSet('createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords');
363
364 $localizedContentId = $localizedTableIds[self::TABLE_Content][$newContentId];
365 $localizedHotelId = $localizedTableIds[self::TABLE_Hotel][$newHotelId];
366 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
367 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', '[Translate to Dansk:] Testing #1');
368
369 // @todo Does not work since children don't point to live-default record
370 /*
371 $this->assertResponseContentStructureHasRecords(
372 $responseContent, self::TABLE_Content . ':' . $localizedContentId, 'tx_irretutorial_hotels',
373 self::TABLE_Hotel, 'title', '[Translate to Dansk:] Hotel #1'
374 );
375 $this->assertResponseContentStructureHasRecords(
376 $responseContent, self::TABLE_Hotel . ':' . $localizedHotelId, 'offers',
377 self::TABLE_Offer, 'title', '[Translate to Dansk:] Offer #1'
378 );
379 */
380 }
381
382 /**
383 * @test
384 */
385 public function createAndLocalizeParentContentRecordWithHotelAndOfferChildRecordsAndDiscardLocalizedParentRecord() {
386 // @todo Localizing the new child records is broken in the Core
387 $newTableIds = $this->actionService->createNewRecords(
388 self::VALUE_PageId,
389 array(
390 self::TABLE_Offer => array('title' => 'Offer #1'),
391 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
392 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
393 )
394 );
395 $newContentId = $newTableIds[self::TABLE_Content][0];
396 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $newContentId, self::VALUE_LanguageId);
397 $localizedContentId = $localizedTableIds[self::TABLE_Content][$newContentId];
398 $versionedLocalizedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, $localizedContentId);
399 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedLocalizedContentId);
400 $this->assertAssertionDataSet('createAndLocalizeParentContentRecordWithHotelAndOfferChildRecordsAndDiscardLocalizedParentRecord');
401
402 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
403 $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', '[Translate to Dansk:] Testing #1');
404 }
405
406 /**
407 * @test
408 */
409 public function modifyOnlyHotelChildRecord() {
410 $this->actionService->modifyRecord(self::TABLE_Hotel, 4, array('title' => 'Testing #1'));
411 $this->assertAssertionDataSet('modifyOnlyHotelChildRecord');
412
413 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
414 $this->assertResponseContentStructureHasRecords(
415 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
416 self::TABLE_Hotel, 'title', array('Hotel #1', 'Testing #1')
417 );
418 }
419
420 /**
421 * @test
422 */
423 public function modifyParentRecordAndChangeHotelChildRecordsSorting() {
424 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('tx_irretutorial_hotels' => '4,3'));
425 $this->assertAssertionDataSet('modifyParentRecordAndChangeHotelChildRecordsSorting');
426
427 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
428 $this->assertResponseContentStructureHasRecords(
429 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
430 self::TABLE_Hotel, 'title', array('Hotel #2', 'Hotel #1')
431 );
432 }
433
434 /**
435 * @test
436 */
437 public function modifyParentRecordWithHotelChildRecord() {
438 $this->actionService->modifyRecords(
439 self::VALUE_PageId,
440 array(
441 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
442 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels' => '3,4'),
443 )
444 );
445 $this->assertAssertionDataSet('modifyParentRecordWithHotelChildRecord');
446
447 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
448 $this->assertResponseContentStructureHasRecords(
449 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
450 self::TABLE_Hotel, 'title', array('Hotel #1', 'Testing #1')
451 );
452 }
453
454 /**
455 * @test
456 */
457 public function modifyParentRecordWithHotelChildRecordAndDiscardModifiedParentRecord() {
458 $this->actionService->modifyRecords(
459 self::VALUE_PageId,
460 array(
461 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
462 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels' => '3,4'),
463 )
464 );
465 $modifiedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
466 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $modifiedContentId);
467 $this->assertAssertionDataSet('modifyParentRecordWithHotelChildRecordAndDiscardModifiedParentRecord');
468
469 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
470 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Regular Element #1');
471 $this->assertResponseContentStructureHasRecords(
472 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
473 self::TABLE_Hotel, 'title', array('Hotel #1', 'Testing #1')
474 // @todo Discarding the parent record should discard the child records as well
475 // self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2')
476 );
477 /*
478 $this->assertResponseContentStructureDoesNotHaveRecords(
479 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
480 self::TABLE_Hotel, 'title', 'Testing #1'
481 );
482 */
483 }
484
485 /**
486 * @test
487 */
488 public function modifyParentRecordWithHotelChildRecordAndDiscardAllModifiedRecords() {
489 $this->actionService->modifyRecords(
490 self::VALUE_PageId,
491 array(
492 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
493 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels' => '3,4'),
494 )
495 );
496 $modifiedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
497 $modifiedHotelId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Hotel, 4);
498 $this->actionService->clearWorkspaceRecords(
499 array(
500 self::TABLE_Hotel => array($modifiedHotelId),
501 self::TABLE_Content => array($modifiedContentId),
502 )
503 );
504 $this->assertAssertionDataSet('modifyParentRecordWithHotelChildRecordAndDiscardAllModifiedRecords');
505
506 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
507 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Regular Element #1');
508 $this->assertResponseContentStructureHasRecords(
509 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
510 self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2')
511 );
512 }
513
514 /**
515 * @test
516 */
517 public function modifyParentRecordAndAddHotelChildRecord() {
518 $this->actionService->modifyRecords(
519 self::VALUE_PageId,
520 array(
521 self::TABLE_Hotel => array('uid' => '__NEW', 'title' => 'Hotel #2'),
522 self::TABLE_Content => array('uid' => self::VALUE_ContentIdLast, 'tx_irretutorial_hotels' => '5,__previousUid'),
523 )
524 );
525 $this->assertAssertionDataSet('modifyParentRecordAndAddHotelChildRecord');
526
527 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
528
529 // @todo Child record cannot be selected since they do not point to the live record
530 /*
531 $this->assertResponseContentStructureHasRecords(
532 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
533 self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2')
534 );
535 */
536 }
537
538 /**
539 * @test
540 */
541 public function modifyParentRecordAndDeleteHotelChildRecord() {
542 $this->actionService->modifyRecord(
543 self::TABLE_Content,
544 self::VALUE_ContentIdFirst,
545 array('tx_irretutorial_hotels' => '3'),
546 array(self::TABLE_Hotel => array(4))
547 );
548 $this->assertAssertionDataSet('modifyParentRecordAndDeleteHotelChildRecord');
549
550 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
551 $this->assertResponseContentStructureHasRecords(
552 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
553 self::TABLE_Hotel, 'title', 'Hotel #1'
554 );
555 $this->assertResponseContentStructureDoesNotHaveRecords(
556 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
557 self::TABLE_Hotel, 'title', 'Hotel #2'
558 );
559 }
560
561 }