783d8221c00d22b4bc4bfa9a280327daa708cc36
[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/Assertion/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/Assertion/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/Assertion/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/Assertion/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/Assertion/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/Assertion/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/Assertion/localizeContentRecord.csv
154 */
155 public function localizeContent()
156 {
157 parent::localizeContent();
158 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
159 $this->assertAssertionDataSet('localizeContent');
160
161 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
162 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
163 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
164 }
165
166 /**
167 * @test
168 * @see DataSet/Assertion/changeContentRecordSorting.csv
169 */
170 public function changeContentSorting()
171 {
172 parent::changeContentSorting();
173 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
174 $this->assertAssertionDataSet('changeContentSorting');
175
176 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
177 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
178 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
179 }
180
181 /**
182 * @test
183 * @see DataSet/Assertion/moveContentRecordToDifferentPage.csv
184 */
185 public function moveContentToDifferentPage()
186 {
187 parent::moveContentToDifferentPage();
188 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
189 $this->assertAssertionDataSet('moveContentToDifferentPage');
190
191 $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
192 $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
193 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
194 $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
195 $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
196 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
197 }
198
199 /**
200 * @test
201 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
202 */
203 public function moveContentToDifferentPageAndChangeSorting()
204 {
205 parent::moveContentToDifferentPageAndChangeSorting();
206 $this->actionService->publishRecords(
207 [
208 self::TABLE_Content => [self::VALUE_ContentIdFirst, self::VALUE_ContentIdSecond],
209 ]
210 );
211 $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
212
213 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
214 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
215 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
216 }
217
218 /**
219 * Page records
220 */
221
222 /**
223 * @test
224 * @see DataSet/Assertion/createPageRecord.csv
225 */
226 public function createPage()
227 {
228 parent::createPage();
229 $this->actionService->publishRecord(self::TABLE_Page, $this->recordIds['newPageId']);
230 $this->assertAssertionDataSet('createPage');
231
232 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
233 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
234 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
235 }
236
237 /**
238 * @test
239 * @see DataSet/Assertion/modifyPageRecord.csv
240 */
241 public function modifyPage()
242 {
243 parent::modifyPage();
244 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
245 $this->assertAssertionDataSet('modifyPage');
246
247 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
248 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
249 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
250 }
251
252 /**
253 * @test
254 * @see DataSet/Assertion/deletePageRecord.csv
255 */
256 public function deletePage()
257 {
258 parent::deletePage();
259 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
260 $this->assertAssertionDataSet('deletePage');
261
262 $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, false);
263 $this->assertContains('PageNotFoundException', $response->getError());
264 }
265
266 /**
267 * @test
268 * @see DataSet/Assertion/copyPageRecord.csv
269 */
270 public function copyPage()
271 {
272 parent::copyPage();
273 $this->actionService->publishRecords(
274 [
275 self::TABLE_Page => [$this->recordIds['newPageId']],
276 self::TABLE_Content => [$this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']],
277 ]
278 );
279 $this->assertAssertionDataSet('copyPage');
280
281 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
282 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
283 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
284 }
285
286 /**
287 * @test
288 * @see DataSet/Assertion/localizePageRecord.csv
289 */
290 public function localizePage()
291 {
292 parent::localizePage();
293 $this->actionService->publishRecord(self::TABLE_PageOverlay, $this->recordIds['localizedPageOverlayId']);
294 $this->assertAssertionDataSet('localizePage');
295
296 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
297 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
298 ->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
299 }
300
301 /**
302 * @test
303 * @see DataSet/Assertion/changePageRecordSorting.csv
304 */
305 public function changePageSorting()
306 {
307 parent::changePageSorting();
308 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
309 $this->assertAssertionDataSet('changePageSorting');
310
311 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
312 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
313 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
314 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
315 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
316 }
317
318 /**
319 * @test
320 * @see DataSet/Assertion/movePageRecordToDifferentPage.csv
321 */
322 public function movePageToDifferentPage()
323 {
324 parent::movePageToDifferentPage();
325 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
326 $this->assertAssertionDataSet('movePageToDifferentPage');
327
328 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
329 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
330 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
331 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
332 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
333 }
334
335 /**
336 * @test
337 * @see DataSet/Assertion/movePageRecordToDifferentPageAndChangeSorting.csv
338 */
339 public function movePageToDifferentPageAndChangeSorting()
340 {
341 parent::movePageToDifferentPageAndChangeSorting();
342 $this->actionService->publishRecords(
343 [
344 self::TABLE_Page => [self::VALUE_PageId, self::VALUE_PageIdTarget],
345 ]
346 );
347 $this->assertAssertionDataSet('movePageToDifferentPageNChangeSorting');
348
349 $responseSectionsPage = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
350 $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
351 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
352 $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
353 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
354 $responseSectionsWebsite = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
355 $this->assertThat($responseSectionsWebsite, $this->getRequestSectionStructureHasRecordConstraint()
356 ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
357 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Relations', 'DataHandlerTest'));
358 }
359
360 /**
361 * @test
362 * @see DataSet/Assertion/movePageRecordToDifferentPageAndCreatePageRecordAfterMovedPageRecord.csv
363 * @see http://forge.typo3.org/issues/33104
364 * @see http://forge.typo3.org/issues/55573
365 */
366 public function movePageToDifferentPageAndCreatePageAfterMovedPage()
367 {
368 parent::movePageToDifferentPageAndCreatePageAfterMovedPage();
369 $this->actionService->publishRecords(
370 [
371 self::TABLE_Page => [self::VALUE_PageIdTarget, $this->recordIds['newPageId']],
372 ]
373 );
374 $this->assertAssertionDataSet('movePageToDifferentPageNCreatePageAfterMovedPage');
375
376 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
377 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
378 ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
379 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Testing #1', 'DataHandlerTest'));
380 }
381
382 /**
383 * @test
384 * @see DataSet/createPlaceholdersAndDeleteDraftParentPage.csv
385 */
386 public function createPlaceholdersAndDeleteDraftParentPage()
387 {
388 parent::createPlaceholdersAndDeleteDraftParentPage();
389 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_ParentPageId);
390 $this->assertAssertionDataSet('createPlaceholdersAndDeleteDraftParentPage');
391 }
392 }