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