[TASK] Streamline workspace DataHandler functional tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / Regular / Publish / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Regular\Publish;
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\Workspaces\Tests\Functional\DataHandling\Regular\AbstractActionTestCase
21 {
22 /**
23 * @var string
24 */
25 protected $assertionDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/Publish/DataSet/';
26
27 /**
28 * Content records
29 */
30
31 /**
32 * @test
33 * @see DataSet/createContentRecords.csv
34 */
35 public function createContents()
36 {
37 parent::createContents();
38 $this->actionService->publishRecords(
39 [
40 self::TABLE_Content => [$this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']],
41 ]
42 );
43 $this->assertAssertionDataSet('createContents');
44
45 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
46 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
47 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1', 'Testing #2'));
48 }
49
50 /**
51 * @test
52 * @see DataSet/createContentRecordAndDiscardCreatedContentRecord.csv
53 */
54 public function createContentAndDiscardCreatedContent()
55 {
56 parent::createContentAndDiscardCreatedContent();
57 // Actually this is not required, since there's nothing to publish... but it's a test case!
58 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId'], false);
59 $this->assertAssertionDataSet('createContentNDiscardCreatedContent');
60
61 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
62 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
63 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
64 }
65
66 /**
67 * @test
68 * @see DataSet/createAndCopyContentRecordAndDiscardCopiedContentRecord.csv
69 */
70 public function createAndCopyContentAndDiscardCopiedContent()
71 {
72 parent::createAndCopyContentAndDiscardCopiedContent();
73 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
74 // Actually this is not required, since there's nothing to publish... but it's a test case!
75 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId'], false);
76 $this->assertAssertionDataSet('createNCopyContentNDiscardCopiedContent');
77
78 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
79 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
80 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
81 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
82 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1 (copy 1)'));
83 }
84
85 /**
86 * @test
87 * @see DataSet/modifyContentRecord.csv
88 */
89 public function modifyContent()
90 {
91 parent::modifyContent();
92 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
93 $this->assertAssertionDataSet('modifyContent');
94
95 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
96 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
97 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
98 }
99
100 /**
101 * @test
102 * @see DataSet/deleteContentRecord.csv
103 */
104 public function deleteContent()
105 {
106 parent::deleteContent();
107 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
108 $this->assertAssertionDataSet('deleteContent');
109
110 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
111 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
112 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
113 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
114 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
115 }
116
117 /**
118 * @test
119 * @see DataSet/deleteLocalizedContentNDeleteContent.csv
120 */
121 public function deleteLocalizedContentAndDeleteContent()
122 {
123 parent::deleteLocalizedContentAndDeleteContent();
124 $this->actionService->publishRecords(
125 [
126 self::TABLE_Content => [self::VALUE_ContentIdThird, self::VALUE_ContentIdThirdLocalized],
127 ]
128 );
129 $this->assertAssertionDataSet('deleteLocalizedContentNDeleteContent');
130
131 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
132 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
133 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #3', '[Translate to Dansk:] Regular Element #3'));
134 }
135
136 /**
137 * @test
138 * @see DataSet/copyContentRecord.csv
139 */
140 public function copyContent()
141 {
142 parent::copyContent();
143 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
144 $this->assertAssertionDataSet('copyContent');
145
146 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
147 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
148 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
149 }
150
151 /**
152 * @test
153 * @see DataSet/copyContentToLanguage.csv
154 */
155 public function copyContentToLanguage()
156 {
157 parent::copyContentToLanguage();
158 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
159 $this->assertAssertionDataSet('copyContentToLanguage');
160
161 $this->setUpFrontendRootPage(1, [
162 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
163 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRendererNoOverlay.ts'
164 ]);
165 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
166 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
167 ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #3', '[Translate to Dansk:] Regular Element #2'));
168 }
169
170 /**
171 * @test
172 * @see DataSet/copyContentToLanguageFromNonDefaultLanguage.csv
173 */
174 public function copyContentToLanguageFromNonDefaultLanguage()
175 {
176 parent::copyContentToLanguageFromNonDefaultLanguage();
177 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
178 $this->assertAssertionDataSet('copyContentToLanguageFromNonDefaultLanguage');
179
180 $this->setUpFrontendRootPage(1, [
181 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
182 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRendererNoOverlay.ts'
183 ]);
184 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageIdSecond)->getResponseSections();
185 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
186 ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Deutsch:] [Translate to Dansk:] Regular Element #3'));
187 }
188
189 /**
190 * @test
191 * @see DataSet/localizeContentRecord.csv
192 */
193 public function localizeContent()
194 {
195 parent::localizeContent();
196 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
197 $this->assertAssertionDataSet('localizeContent');
198
199 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
200 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
201 ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
202 }
203
204 /**
205 * @test
206 * @see DataSet/localizeContentFromNonDefaultLanguage.csv
207 */
208 public function localizeContentFromNonDefaultLanguage()
209 {
210 parent::localizeContentFromNonDefaultLanguage();
211 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
212 $this->assertAssertionDataSet('localizeContentFromNonDefaultLanguage');
213
214 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageIdSecond)->getResponseSections();
215 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
216 ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1', '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #3'));
217 }
218
219 /**
220 * @test
221 * @see DataSet/changeContentRecordSorting.csv
222 */
223 public function changeContentSorting()
224 {
225 parent::changeContentSorting();
226 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
227 $this->assertAssertionDataSet('changeContentSorting');
228
229 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
230 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
231 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
232 }
233
234 /**
235 * @test
236 * @see DataSet/moveContentRecordToDifferentPage.csv
237 */
238 public function moveContentToDifferentPage()
239 {
240 parent::moveContentToDifferentPage();
241 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
242 $this->assertAssertionDataSet('moveContentToDifferentPage');
243
244 $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
245 $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
246 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
247 $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
248 $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
249 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
250 }
251
252 /**
253 * @test
254 * @see DataSet/moveContentRecordToDifferentPageAndChangeSorting.csv
255 */
256 public function moveContentToDifferentPageAndChangeSorting()
257 {
258 parent::moveContentToDifferentPageAndChangeSorting();
259 $this->actionService->publishRecords(
260 [
261 self::TABLE_Content => [self::VALUE_ContentIdFirst, self::VALUE_ContentIdSecond],
262 ]
263 );
264 $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
265
266 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
267 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
268 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
269 }
270
271 /**
272 * Page records
273 */
274
275 /**
276 * @test
277 * @see DataSet/createPageRecord.csv
278 */
279 public function createPage()
280 {
281 parent::createPage();
282 $this->actionService->publishRecord(self::TABLE_Page, $this->recordIds['newPageId']);
283 $this->assertAssertionDataSet('createPage');
284
285 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
286 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
287 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
288 }
289
290 /**
291 * @test
292 * @see DataSet/modifyPageRecord.csv
293 */
294 public function modifyPage()
295 {
296 parent::modifyPage();
297 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
298 $this->assertAssertionDataSet('modifyPage');
299
300 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
301 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
302 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
303 }
304
305 /**
306 * @test
307 * @see DataSet/deletePageRecord.csv
308 */
309 public function deletePage()
310 {
311 parent::deletePage();
312 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
313 $this->assertAssertionDataSet('deletePage');
314
315 $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, false);
316 $this->assertContains('PageNotFoundException', $response->getError());
317 }
318
319 /**
320 * @test
321 * @see DataSet/deleteContentAndPage.csv
322 */
323 public function deleteContentAndPage()
324 {
325 parent::deleteContentAndPage();
326 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
327 $this->assertAssertionDataSet('deleteContentAndPage');
328
329 $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, false);
330 $this->assertContains('PageNotFoundException', $response->getError());
331 }
332
333 /**
334 * @test
335 * @see DataSet/copyPageRecord.csv
336 */
337 public function copyPage()
338 {
339 parent::copyPage();
340 $this->actionService->publishRecords(
341 [
342 self::TABLE_Page => [$this->recordIds['newPageId']],
343 self::TABLE_Content => [$this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']],
344 ]
345 );
346 $this->assertAssertionDataSet('copyPage');
347
348 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
349 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
350 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
351 }
352
353 /**
354 * @test
355 * @see DataSet/copyPageFreeMode.csv
356 */
357 public function copyPageFreeMode()
358 {
359 parent::copyPageFreeMode();
360 $this->actionService->publishRecords(
361 [
362 self::TABLE_Page => [$this->recordIds['newPageId']],
363 self::TABLE_Content => [$this->recordIds['newContentIdTenth'], $this->recordIds['newContentIdTenthLocalized'], $this->recordIds['newContentIdTenthLocalized2']],
364 ]
365 );
366 $this->assertAssertionDataSet('copyPageFreeMode');
367
368 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
369 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
370 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target'));
371 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
372 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #10'));
373 }
374
375 /**
376 * @test
377 * @see DataSet/localizePageRecord.csv
378 */
379 public function localizePage()
380 {
381 parent::localizePage();
382 $this->actionService->publishRecord(self::TABLE_PageOverlay, $this->recordIds['localizedPageOverlayId']);
383 $this->assertAssertionDataSet('localizePage');
384
385 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
386 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
387 ->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
388 }
389
390 /**
391 * @test
392 * @see DataSet/changePageRecordSorting.csv
393 */
394 public function changePageSorting()
395 {
396 parent::changePageSorting();
397 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
398 $this->assertAssertionDataSet('changePageSorting');
399
400 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
401 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
402 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
403 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
404 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
405 }
406
407 /**
408 * @test
409 * @see DataSet/movePageRecordToDifferentPage.csv
410 */
411 public function movePageToDifferentPage()
412 {
413 parent::movePageToDifferentPage();
414 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
415 $this->assertAssertionDataSet('movePageToDifferentPage');
416
417 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
418 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
419 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
420 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
421 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
422 }
423
424 /**
425 * @test
426 * @see DataSet/movePageRecordToDifferentPageAndChangeSorting.csv
427 */
428 public function movePageToDifferentPageAndChangeSorting()
429 {
430 parent::movePageToDifferentPageAndChangeSorting();
431 $this->actionService->publishRecords(
432 [
433 self::TABLE_Page => [self::VALUE_PageId, self::VALUE_PageIdTarget],
434 ]
435 );
436 $this->assertAssertionDataSet('movePageToDifferentPageNChangeSorting');
437
438 $responseSectionsPage = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
439 $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
440 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
441 $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
442 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
443 $responseSectionsWebsite = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
444 $this->assertThat($responseSectionsWebsite, $this->getRequestSectionStructureHasRecordConstraint()
445 ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
446 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Relations', 'DataHandlerTest'));
447 }
448
449 /**
450 * @test
451 * @see DataSet/movePageRecordToDifferentPageAndCreatePageRecordAfterMovedPageRecord.csv
452 * @see http://forge.typo3.org/issues/33104
453 * @see http://forge.typo3.org/issues/55573
454 */
455 public function movePageToDifferentPageAndCreatePageAfterMovedPage()
456 {
457 parent::movePageToDifferentPageAndCreatePageAfterMovedPage();
458 $this->actionService->publishRecords(
459 [
460 self::TABLE_Page => [self::VALUE_PageIdTarget, $this->recordIds['newPageId']],
461 ]
462 );
463 $this->assertAssertionDataSet('movePageToDifferentPageNCreatePageAfterMovedPage');
464
465 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
466 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
467 ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
468 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Testing #1', 'DataHandlerTest'));
469 }
470
471 /**
472 * @test
473 * @see DataSet/createPlaceholdersAndDeleteDraftParentPage.csv
474 */
475 public function createPlaceholdersAndDeleteDraftParentPage()
476 {
477 parent::createPlaceholdersAndDeleteDraftParentPage();
478 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_ParentPageId);
479 $this->assertAssertionDataSet('createPlaceholdersAndDeleteDraftParentPage');
480 }
481 }