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