[TASK] Extend DataHandler IRRE functional 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
41 const TABLE_Page = 'pages';
42 const TABLE_Content = 'tt_content';
43 const TABLE_Hotel = 'tx_irretutorial_1nff_hotel';
44 const TABLE_Offer = 'tx_irretutorial_1nff_offer';
45
46 /**
47 * @var string
48 */
49 protected $dataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/InlineRelationalRecordEditing/ForeignField/DataSet/';
50
51 /**
52 * @var array
53 */
54 protected $coreExtensionsToLoad = array(
55 'version',
56 'workspaces',
57 );
58
59 public function setUp() {
60 parent::setUp();
61 $this->importScenarioDataSet('LiveDefaultPages');
62 $this->importScenarioDataSet('LiveDefaultElements');
63 }
64
65 /**
66 * Parent content records
67 */
68
69 /**
70 * @test
71 */
72 public function createParentContentRecord() {
73 $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
74 $this->assertAssertionDataSet('createParentContentRecord');
75 }
76
77 /**
78 * @test
79 */
80 public function modifyParentContentRecord() {
81 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, array('header' => 'Testing #1'));
82 $this->assertAssertionDataSet('modifyParentContentRecord');
83 }
84
85 /**
86 * @test
87 */
88 public function deleteParentContentRecord() {
89 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
90 $this->assertAssertionDataSet('deleteParentContentRecord');
91 }
92
93 /**
94 * @test
95 */
96 public function copyParentContentRecord() {
97 $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
98 $this->assertAssertionDataSet('copyParentContentRecord');
99 }
100
101 /**
102 * @test
103 */
104 public function localizeParentContentRecord() {
105 $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
106 $this->assertAssertionDataSet('localizeParentContentRecord');
107 }
108
109 /**
110 * @test
111 */
112 public function changeParentContentRecordSorting() {
113 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
114 $this->assertAssertionDataSet('changeParentContentRecordSorting');
115 }
116
117 /**
118 * @test
119 */
120 public function moveParentContentRecordToDifferentPage() {
121 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
122 $this->assertAssertionDataSet('moveParentContentRecordToDifferentPage');
123 }
124
125 /**
126 * @test
127 */
128 public function moveParentContentRecordToDifferentPageAndChangeSorting() {
129 $this->markTestSkipped('Something seems to be wrong here...');
130 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
131 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
132 $this->assertAssertionDataSet('moveParentContentRecordToDifferentPageAndChangeSorting');
133 }
134
135 /**
136 * Page records
137 */
138
139 /**
140 * @test
141 */
142 public function modifyPageRecord() {
143 $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1'));
144 $this->assertAssertionDataSet('modifyPageRecord');
145 }
146
147 /**
148 * @test
149 */
150 public function deletePageRecord() {
151 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
152 $this->assertAssertionDataSet('deletePageRecord');
153 }
154
155 /**
156 * @test
157 */
158 public function copyPageRecord() {
159 $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
160 $this->assertAssertionDataSet('copyPageRecord');
161 }
162
163 /**
164 * IRRE Child Records
165 */
166
167 /**
168 * @test
169 */
170 public function createParentContentRecordWithHotelAndOfferChildRecords() {
171 $this->actionService->createNewRecords(
172 self::VALUE_PageId,
173 array(
174 self::TABLE_Offer => array('title' => 'Offer #1'),
175 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
176 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
177 )
178 );
179 $this->assertAssertionDataSet('createParentContentRecordWithHotelAndOfferChildRecords');
180 }
181
182 /**
183 * @test
184 */
185 public function createAndCopyParentContentRecordWithHotelAndOfferChildRecords() {
186 // @todo Copying the new child records is broken in the Core
187 $newTableIds = $this->actionService->createNewRecords(
188 self::VALUE_PageId,
189 array(
190 self::TABLE_Offer => array('title' => 'Offer #1'),
191 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
192 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
193 )
194 );
195 $newContentId = $newTableIds['tt_content'][0];
196 $this->actionService->copyRecord(self::TABLE_Content, $newContentId, self::VALUE_PageId);
197 $this->assertAssertionDataSet('createAndCopyParentContentRecordWithHotelAndOfferChildRecords');
198 }
199
200 /**
201 * @test
202 */
203 public function createAndCopyParentContentRecordWithHotelAndOfferChildRecordsAndDiscardCopiedParentRecord() {
204 // @todo Copying the new child records is broken in the Core
205 $newTableIds = $this->actionService->createNewRecords(
206 self::VALUE_PageId,
207 array(
208 self::TABLE_Offer => array('title' => 'Offer #1'),
209 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
210 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
211 )
212 );
213 $newContentId = $newTableIds['tt_content'][0];
214 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $newContentId, self::VALUE_PageId);
215 $copiedContentId = $copiedTableIds[self::TABLE_Content][$newContentId];
216 $this->actionService->deleteRecord(self::TABLE_Content, $copiedContentId);
217 $this->assertAssertionDataSet('createAndCopyParentContentRecordWithHotelAndOfferChildRecordsAndDiscardCopiedParentRecord');
218 }
219
220 /**
221 * @test
222 */
223 public function createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords() {
224 // @todo Localizing the new child records is broken in the Core
225 $newTableIds = $this->actionService->createNewRecords(
226 self::VALUE_PageId,
227 array(
228 self::TABLE_Offer => array('title' => 'Offer #1'),
229 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
230 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
231 )
232 );
233 $newContentId = $newTableIds[self::TABLE_Content][0];
234 $newHotelId = $newTableIds[self::TABLE_Hotel][0];
235 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $newContentId, self::VALUE_LanguageId);
236 $this->assertAssertionDataSet('createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords');
237 }
238
239 /**
240 * @test
241 */
242 public function createAndLocalizeParentContentRecordWithHotelAndOfferChildRecordsAndDiscardLocalizedParentRecord() {
243 // @todo Localizing the new child records is broken in the Core
244 $newTableIds = $this->actionService->createNewRecords(
245 self::VALUE_PageId,
246 array(
247 self::TABLE_Offer => array('title' => 'Offer #1'),
248 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
249 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
250 )
251 );
252 $newContentId = $newTableIds[self::TABLE_Content][0];
253 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $newContentId, self::VALUE_LanguageId);
254 $localizedContentId = $localizedTableIds[self::TABLE_Content][$newContentId];
255 $this->actionService->deleteRecord(self::TABLE_Content, $localizedContentId);
256 $this->assertAssertionDataSet('createAndLocalizeParentContentRecordWithHotelAndOfferChildRecordsAndDiscardLocalizedParentRecord');
257 }
258
259 /**
260 * @test
261 */
262 public function modifyOnlyHotelChildRecord() {
263 $this->actionService->modifyRecord(self::TABLE_Hotel, 4, array('title' => 'Testing #1'));
264 $this->assertAssertionDataSet('modifyOnlyHotelChildRecord');
265 }
266
267 /**
268 * @test
269 */
270 public function modifyParentRecordAndChangeHotelChildRecordsSorting() {
271 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('tx_irretutorial_hotels' => '4,3'));
272 $this->assertAssertionDataSet('modifyParentRecordAndChangeHotelChildRecordsSorting');
273 }
274
275 /**
276 * @test
277 */
278 public function modifyParentRecordWithHotelChildRecord() {
279 $this->actionService->modifyRecords(
280 self::VALUE_PageId,
281 array(
282 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
283 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels' => '3,4'),
284 )
285 );
286 $this->assertAssertionDataSet('modifyParentRecordWithHotelChildRecord');
287 }
288
289 /**
290 * @test
291 */
292 public function modifyParentRecordWithHotelChildRecordAndDiscardModifiedParentRecord() {
293 $this->actionService->modifyRecords(
294 self::VALUE_PageId,
295 array(
296 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
297 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels' => '3,4'),
298 )
299 );
300 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
301 $this->assertAssertionDataSet('modifyParentRecordWithHotelChildRecordAndDiscardModifiedParentRecord');
302 }
303
304 /**
305 * @test
306 */
307 public function modifyParentRecordWithHotelChildRecordAndDiscardAllModifiedRecords() {
308 $this->actionService->modifyRecords(
309 self::VALUE_PageId,
310 array(
311 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
312 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels' => '3,4'),
313 )
314 );
315 $this->actionService->deleteRecords(
316 array(
317 self::TABLE_Hotel => array(4),
318 self::TABLE_Content => array(self::VALUE_ContentIdFirst),
319 )
320 );
321 $this->assertAssertionDataSet('modifyParentRecordWithHotelChildRecordAndDiscardAllModifiedRecords');
322 }
323
324 /**
325 * @test
326 */
327 public function modifyParentRecordAndAddHotelChildRecord() {
328 $this->actionService->modifyRecords(
329 self::VALUE_PageId,
330 array(
331 self::TABLE_Hotel => array('uid' => '__NEW', 'title' => 'Hotel #2'),
332 self::TABLE_Content => array('uid' => self::VALUE_ContentIdLast, 'tx_irretutorial_hotels' => '5,__previousUid'),
333 )
334 );
335 $this->assertAssertionDataSet('modifyParentRecordAndAddHotelChildRecord');
336 }
337
338 /**
339 * @test
340 */
341 public function modifyParentRecordAndDeleteHotelChildRecord() {
342 $this->actionService->modifyRecord(
343 self::TABLE_Content,
344 self::VALUE_ContentIdFirst,
345 array('tx_irretutorial_hotels' => '3'),
346 array(self::TABLE_Hotel => array(4))
347 );
348 $this->assertAssertionDataSet('modifyParentRecordAndDeleteHotelChildRecord');
349 }
350
351 }