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