2661f971e319618df1b2d15d0b647fce8185f8d2
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / IRRE / CSV / Modify / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\IRRE\CSV\Modify;
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 dirname(dirname(__FILE__)) . '/AbstractActionTestCase.php';
28
29 /**
30 * Functional test for the DataHandler
31 */
32 class ActionTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\IRRE\CSV\AbstractActionTestCase {
33
34 /**
35 * @var string
36 */
37 protected $assertionDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/IRRE/CSV/Modify/DataSet/';
38
39 /**
40 * Parent content records
41 */
42
43 /**
44 * @test
45 * @see DataSet/Assertion/createParentContentRecord.csv
46 */
47 public function createParentContent() {
48 parent::createParentContent();
49 $this->assertAssertionDataSet('createParentContent');
50
51 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
52 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
53 }
54
55 /**
56 * @test
57 * @see DataSet/Assertion/modifyParentContentRecord.csv
58 */
59 public function modifyParentContent() {
60 parent::modifyParentContent();
61 $this->assertAssertionDataSet('modifyParentContent');
62
63 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
64 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
65 $this->assertResponseContentStructureHasRecords(
66 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentHotel,
67 self::TABLE_Hotel, 'title', array('Hotel #1')
68 );
69 }
70
71 /**
72 * @test
73 * @see DataSet/Assertion/deleteParentContentRecord.csv
74 */
75 public function deleteParentContent() {
76 parent::deleteParentContent();
77 $this->assertAssertionDataSet('deleteParentContent');
78
79 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
80 $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Regular Element #2');
81 }
82
83 /**
84 * @test
85 * @see DataSet/Assertion/copyParentContentRecord.csv
86 */
87 public function copyParentContent() {
88 parent::copyParentContent();
89 $this->assertAssertionDataSet('copyParentContent');
90
91 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
92 $this->assertResponseContentStructureHasRecords(
93 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], self::FIELD_ContentHotel,
94 self::TABLE_Hotel, 'title', array('Hotel #1')
95 );
96 }
97
98 /**
99 * @test
100 * @see DataSet/copyParentContentToDifferentPage.csv
101 */
102 public function copyParentContentToDifferentPage() {
103 parent::copyParentContentToDifferentPage();
104 $this->assertAssertionDataSet('copyParentContentToDifferentPage');
105
106 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseContent();
107 $this->assertResponseContentStructureHasRecords(
108 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], self::FIELD_ContentHotel,
109 self::TABLE_Hotel, 'title', array('Hotel #1')
110 );
111 }
112
113 /**
114 * @test
115 * @see DataSet/localizeParentContentKeep.csv
116 */
117 public function localizeParentContentInKeepMode() {
118 parent::localizeParentContentInKeepMode();
119 $this->assertAssertionDataSet('localizeParentContentKeep');
120
121 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
122 $this->assertResponseContentStructureDoesNotHaveRecords(
123 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentHotel,
124 self::TABLE_Hotel, 'title', array('[Translate to Dansk:] Hotel #1')
125 );
126 }
127
128 /**
129 * @test
130 * @see DataSet/localizeParentContentWAllChildrenKeep.csv
131 */
132 public function localizeParentContentWithAllChildrenInKeepMode() {
133 parent::localizeParentContentWithAllChildrenInKeepMode();
134 $this->assertAssertionDataSet('localizeParentContentWAllChildrenKeep');
135
136 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
137 $this->assertResponseContentStructureDoesNotHaveRecords(
138 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentHotel,
139 self::TABLE_Hotel, 'title', array('[Translate to Dansk:] Hotel #1')
140 );
141 }
142
143 /**
144 * @test
145 * @see DataSet/localizeParentContentSelect.csv
146 */
147 public function localizeParentContentInSelectMode() {
148 parent::localizeParentContentInSelectMode();
149 $this->assertAssertionDataSet('localizeParentContentSelect');
150
151 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
152 $this->assertResponseContentStructureDoesNotHaveRecords(
153 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentHotel,
154 self::TABLE_Hotel, 'title', array('[Translate to Dansk:] Hotel #1')
155 );
156 }
157
158 /**
159 * @test
160 * @see DataSet/localizeParentContentWAllChildrenSelect.csv
161 */
162 public function localizeParentContentWithAllChildrenInSelectMode() {
163 parent::localizeParentContentWithAllChildrenInSelectMode();
164 $this->assertAssertionDataSet('localizeParentContentWAllChildrenSelect');
165
166 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
167 $this->assertResponseContentStructureHasRecords(
168 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentHotel,
169 self::TABLE_Hotel, 'title', array('[Translate to Dansk:] Hotel #1')
170 );
171 }
172
173 /**
174 * @test
175 * @see DataSet/Assertion/changeParentContentRecordSorting.csv
176 */
177 public function changeParentContentSorting() {
178 parent::changeParentContentSorting();
179 $this->assertAssertionDataSet('changeParentContentSorting');
180
181 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
182 $this->assertResponseContentStructureHasRecords(
183 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentHotel,
184 self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2')
185 );
186 $this->assertResponseContentStructureHasRecords(
187 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentHotel,
188 self::TABLE_Hotel, 'title', array('Hotel #1')
189 );
190 }
191
192 /**
193 * @test
194 * @see DataSet/Assertion/moveParentContentRecordToDifferentPage.csv
195 */
196 public function moveParentContentToDifferentPage() {
197 parent::moveParentContentToDifferentPage();
198 $this->assertAssertionDataSet('moveParentContentToDifferentPage');
199
200 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseContent();
201 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Regular Element #2');
202 $this->assertResponseContentStructureHasRecords(
203 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentHotel,
204 self::TABLE_Hotel, 'title', array('Hotel #1')
205 );
206 }
207
208 /**
209 * @test
210 * @see DataSet/Assertion/moveParentContentRecordToDifferentPageAndChangeSorting.csv
211 */
212 public function moveParentContentToDifferentPageAndChangeSorting() {
213 parent::moveParentContentToDifferentPageAndChangeSorting();
214 $this->assertAssertionDataSet('moveParentContentToDifferentPageNChangeSorting');
215
216 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseContent();
217 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Regular Element #2', 'Regular Element #1'));
218 $this->assertResponseContentStructureHasRecords(
219 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentHotel,
220 self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2')
221 );
222 $this->assertResponseContentStructureHasRecords(
223 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentHotel,
224 self::TABLE_Hotel, 'title', array('Hotel #1')
225 );
226 }
227
228 /**
229 * Page records
230 */
231
232 /**
233 * @test
234 * @see DataSet/Assertion/modifyPageRecord.csv
235 */
236 public function modifyPage() {
237 parent::modifyPage();
238 $this->assertAssertionDataSet('modifyPage');
239
240 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
241 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Page, 'title', 'Testing #1');
242 }
243
244 /**
245 * @test
246 * @see DataSet/Assertion/deletePageRecord.csv
247 */
248 public function deletePage() {
249 parent::deletePage();
250 $this->assertAssertionDataSet('deletePage');
251
252 $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, FALSE);
253 $this->assertContains('PageNotFoundException', $response->getError());
254 }
255
256 /**
257 * @test
258 * @see DataSet/Assertion/copyPageRecord.csv
259 */
260 public function copyPage() {
261 parent::copyPage();
262 $this->assertAssertionDataSet('copyPage');
263
264 $responseContent = $this->getFrontendResponse($this->recordIds['newPageId'])->getResponseContent();
265 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2', 'Hotel #1'));
266 }
267
268 /**
269 * @test
270 * @see DataSet/Assertion/copyPageWHotelBeforeParentContent.csv
271 */
272 public function copyPageWithHotelBeforeParentContent() {
273 parent::copyPageWithHotelBeforeParentContent();
274 $this->assertAssertionDataSet('copyPageWHotelBeforeParentContent');
275
276 $responseContent = $this->getFrontendResponse($this->recordIds['newPageId'])->getResponseContent();
277 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2', 'Hotel #1'));
278 }
279
280 /**
281 * IRRE Child Records
282 */
283
284 /**
285 * @test
286 * @see DataSet/Assertion/createParentContentRecordWithHotelAndOfferChildRecords.csv
287 */
288 public function createParentContentWithHotelAndOfferChildren() {
289 parent::createParentContentWithHotelAndOfferChildren();
290 $this->assertAssertionDataSet('createParentContentNHotelNOfferChildren');
291
292 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
293 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
294 $this->assertResponseContentStructureHasRecords(
295 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], self::FIELD_ContentHotel,
296 self::TABLE_Hotel, 'title', 'Hotel #1'
297 );
298 }
299
300 /**
301 * @test
302 * @see DataSet/Assertion/createAndCopyParentContentRecordWithHotelAndOfferChildRecords.csv
303 */
304 public function createAndCopyParentContentWithHotelAndOfferChildren() {
305 parent::createAndCopyParentContentWithHotelAndOfferChildren();
306 $this->assertAssertionDataSet('createNCopyParentContentNHotelNOfferChildren');
307
308 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
309 $this->assertResponseContentStructureHasRecords(
310 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], self::FIELD_ContentHotel,
311 self::TABLE_Hotel, 'title', 'Hotel #1'
312 );
313 $this->assertResponseContentStructureHasRecords(
314 $responseContent, self::TABLE_Content . ':' . $this->recordIds['copiedContentId'], self::FIELD_ContentHotel,
315 self::TABLE_Hotel, 'title', 'Hotel #1'
316 );
317 $this->assertResponseContentStructureHasRecords(
318 $responseContent, self::TABLE_Hotel . ':' . $this->recordIds['copiedHotelId'], self::FIELD_HotelOffer,
319 self::TABLE_Offer, 'title', 'Offer #1'
320 );
321 }
322
323 /**
324 * @test
325 * @see DataSet/Assertion/createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords.csv
326 */
327 public function createAndLocalizeParentContentWithHotelAndOfferChildren() {
328 parent::createAndLocalizeParentContentWithHotelAndOfferChildren();
329 $this->assertAssertionDataSet('createNLocalizeParentContentNHotelNOfferChildren');
330
331 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
332 // Content record gets overlaid, thus using newContentId
333 $this->assertResponseContentStructureHasRecords(
334 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], self::FIELD_ContentHotel,
335 self::TABLE_Hotel, 'title', '[Translate to Dansk:] Hotel #1'
336 );
337 // Content record directly points to localized child, thus using localizedHotelId
338 $this->assertResponseContentStructureHasRecords(
339 $responseContent, self::TABLE_Hotel . ':' . $this->recordIds['localizedHotelId'], self::FIELD_HotelOffer,
340 self::TABLE_Offer, 'title', '[Translate to Dansk:] Offer #1'
341 );
342 }
343
344 /**
345 * @test
346 * @see DataSet/Assertion/modifyOnlyHotelChildRecord.csv
347 */
348 public function modifyOnlyHotelChild() {
349 parent::modifyOnlyHotelChild();
350 $this->assertAssertionDataSet('modifyOnlyHotelChild');
351
352 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
353 $this->assertResponseContentStructureHasRecords(
354 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentHotel,
355 self::TABLE_Hotel, 'title', array('Hotel #1', 'Testing #1')
356 );
357 }
358
359 /**
360 * @test
361 * @see DataSet/Assertion/modifyParentRecordAndChangeHotelChildRecordsSorting.csv
362 */
363 public function modifyParentAndChangeHotelChildrenSorting() {
364 parent::modifyParentAndChangeHotelChildrenSorting();
365 $this->assertAssertionDataSet('modifyParentNChangeHotelChildrenSorting');
366
367 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
368 $this->assertResponseContentStructureHasRecords(
369 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentHotel,
370 self::TABLE_Hotel, 'title', array('Hotel #2', 'Hotel #1')
371 );
372 }
373
374 /**
375 * @test
376 * @see DataSet/Assertion/modifyParentRecordWithHotelChildRecord.csv
377 */
378 public function modifyParentWithHotelChild() {
379 parent::modifyParentWithHotelChild();
380 $this->assertAssertionDataSet('modifyParentNHotelChild');
381
382 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
383 $this->assertResponseContentStructureHasRecords(
384 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentHotel,
385 self::TABLE_Hotel, 'title', array('Hotel #1', 'Testing #1')
386 );
387 }
388
389 /**
390 * @test
391 * @see DataSet/Assertion/modifyParentRecordAndAddHotelChildRecord.csv
392 */
393 public function modifyParentAndAddHotelChild() {
394 parent::modifyParentAndAddHotelChild();
395 $this->assertAssertionDataSet('modifyParentNAddHotelChild');
396
397 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
398 $this->assertResponseContentStructureHasRecords(
399 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentHotel,
400 self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2')
401 );
402 }
403
404 /**
405 * @test
406 * @see DataSet/Assertion/modifyParentRecordAndDeleteHotelChildRecord.csv
407 */
408 public function modifyParentAndDeleteHotelChild() {
409 parent::modifyParentAndDeleteHotelChild();
410 $this->assertAssertionDataSet('modifyParentNDeleteHotelChild');
411
412 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
413 $this->assertResponseContentStructureHasRecords(
414 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentHotel,
415 self::TABLE_Hotel, 'title', 'Hotel #1'
416 );
417 $this->assertResponseContentStructureDoesNotHaveRecords(
418 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentHotel,
419 self::TABLE_Hotel, 'title', 'Hotel #2'
420 );
421 }
422
423 }