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