[BUGFIX] Skip swapping/publishing of deleted records
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / Regular / PublishAll / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Regular\PublishAll;
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/PublishAll/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->publishWorkspace(self::VALUE_WorkspaceId);
39 $this->assertAssertionDataSet('createContents');
40
41 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
42 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
43 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1', 'Testing #2'));
44 }
45
46 /**
47 * @test
48 * @see DataSet/Assertion/createContentRecordAndDiscardCreatedContentRecord.csv
49 */
50 public function createContentAndDiscardCreatedContent()
51 {
52 parent::createContentAndDiscardCreatedContent();
53 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
54 $this->assertAssertionDataSet('createContentNDiscardCreatedContent');
55
56 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
57 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
58 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
59 }
60
61 /**
62 * @test
63 * @see DataSet/Assertion/createAndCopyContentRecordAndDiscardCopiedContentRecord.csv
64 */
65 public function createAndCopyContentAndDiscardCopiedContent()
66 {
67 parent::createAndCopyContentAndDiscardCopiedContent();
68 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
69 $this->assertAssertionDataSet('createNCopyContentNDiscardCopiedContent');
70
71 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
72 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
73 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
74 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
75 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1 (copy 1)'));
76 }
77
78 /**
79 * @test
80 * @see DataSet/Assertion/modifyContentRecord.csv
81 */
82 public function modifyContent()
83 {
84 parent::modifyContent();
85 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
86 $this->assertAssertionDataSet('modifyContent');
87
88 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
89 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
90 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
91 }
92
93 /**
94 * @test
95 * @see DataSet/Assertion/deleteContentRecord.csv
96 */
97 public function deleteContent()
98 {
99 parent::deleteContent();
100 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
101 $this->assertAssertionDataSet('deleteContent');
102
103 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
104 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
105 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
106 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
107 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
108 }
109
110 /**
111 * @test
112 * @see DataSet/deleteLocalizedContentNDeleteContent.csv
113 */
114 public function deleteLocalizedContentAndDeleteContent()
115 {
116 parent::deleteLocalizedContentAndDeleteContent();
117 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
118 $this->assertAssertionDataSet('deleteLocalizedContentNDeleteContent');
119
120 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
121 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
122 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #3', '[Translate to Dansk:] Regular Element #3'));
123 }
124
125 /**
126 * @test
127 * @see DataSet/Assertion/copyContentRecord.csv
128 */
129 public function copyContent()
130 {
131 parent::copyContent();
132 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
133 $this->assertAssertionDataSet('copyContent');
134
135 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
136 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
137 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
138 }
139
140 /**
141 * @test
142 * @see DataSet/Assertion/localizeContentRecord.csv
143 */
144 public function localizeContent()
145 {
146 parent::localizeContent();
147 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
148 $this->assertAssertionDataSet('localizeContent');
149
150 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
151 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
152 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
153 }
154
155 /**
156 * @test
157 * @see DataSet/localizeContentFromNonDefaultLanguage.csv
158 */
159 public function localizeContentFromNonDefaultLanguage()
160 {
161 parent::localizeContentFromNonDefaultLanguage();
162 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
163 $this->assertAssertionDataSet('localizeContentFromNonDefaultLanguage');
164
165 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageIdSecond)->getResponseSections();
166 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
167 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #3'));
168 }
169
170 /**
171 * @test
172 * @see DataSet/Assertion/changeContentRecordSorting.csv
173 */
174 public function changeContentSorting()
175 {
176 parent::changeContentSorting();
177 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
178 $this->assertAssertionDataSet('changeContentSorting');
179
180 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
181 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
182 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
183 }
184
185 /**
186 * @test
187 * @see DataSet/Assertion/moveContentRecordToDifferentPage.csv
188 */
189 public function moveContentToDifferentPage()
190 {
191 parent::moveContentToDifferentPage();
192 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
193 $this->assertAssertionDataSet('moveContentToDifferentPage');
194
195 $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
196 $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
197 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
198 $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
199 $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
200 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
201 }
202
203 /**
204 * @test
205 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
206 */
207 public function moveContentToDifferentPageAndChangeSorting()
208 {
209 parent::moveContentToDifferentPageAndChangeSorting();
210 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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/deleteContentAndPage.csv
269 */
270 public function deleteContentAndPage()
271 {
272 parent::deleteContentAndPage();
273 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
274 $this->assertAssertionDataSet('deleteContentAndPage');
275
276 $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, false);
277 $this->assertContains('PageNotFoundException', $response->getError());
278 }
279
280 /**
281 * @test
282 * @see DataSet/Assertion/copyPageRecord.csv
283 */
284 public function copyPage()
285 {
286 parent::copyPage();
287 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
288 $this->assertAssertionDataSet('copyPage');
289
290 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
291 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
292 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
293 }
294
295 /**
296 * @test
297 * @see DataSet/Assertion/localizePageRecord.csv
298 */
299 public function localizePage()
300 {
301 parent::localizePage();
302 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
303 $this->assertAssertionDataSet('localizePage');
304
305 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
306 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
307 ->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
308 }
309
310 /**
311 * @test
312 * @see DataSet/Assertion/changePageRecordSorting.csv
313 */
314 public function changePageSorting()
315 {
316 parent::changePageSorting();
317 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
318 $this->assertAssertionDataSet('changePageSorting');
319
320 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
321 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
322 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
323 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
324 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
325 }
326
327 /**
328 * @test
329 * @see DataSet/Assertion/movePageRecordToDifferentPage.csv
330 */
331 public function movePageToDifferentPage()
332 {
333 parent::movePageToDifferentPage();
334 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
335 $this->assertAssertionDataSet('movePageToDifferentPage');
336
337 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
338 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
339 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
340 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
341 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
342 }
343
344 /**
345 * @test
346 * @see DataSet/Assertion/movePageRecordToDifferentPageAndChangeSorting.csv
347 */
348 public function movePageToDifferentPageAndChangeSorting()
349 {
350 parent::movePageToDifferentPageAndChangeSorting();
351 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
352 $this->assertAssertionDataSet('movePageToDifferentPageNChangeSorting');
353
354 $responseSectionsPage = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
355 $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
356 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
357 $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
358 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
359 $responseSectionsWebsite = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
360 $this->assertThat($responseSectionsWebsite, $this->getRequestSectionStructureHasRecordConstraint()
361 ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
362 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Relations', 'DataHandlerTest'));
363 }
364
365 /**
366 * @test
367 * @see DataSet/Assertion/movePageRecordToDifferentPageAndCreatePageRecordAfterMovedPageRecord.csv
368 * @see http://forge.typo3.org/issues/33104
369 * @see http://forge.typo3.org/issues/55573
370 */
371 public function movePageToDifferentPageAndCreatePageAfterMovedPage()
372 {
373 parent::movePageToDifferentPageAndCreatePageAfterMovedPage();
374 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
375 $this->assertAssertionDataSet('movePageToDifferentPageNCreatePageAfterMovedPage');
376
377 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
378 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
379 ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
380 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Testing #1', 'DataHandlerTest'));
381 }
382
383 /**
384 * @test
385 * @see DataSet/createPlaceholdersAndDeleteDraftParentPage.csv
386 */
387 public function createPlaceholdersAndDeleteDraftParentPage()
388 {
389 parent::createPlaceholdersAndDeleteDraftParentPage();
390 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
391 $this->assertAssertionDataSet('createPlaceholdersAndDeleteDraftParentPage');
392 }
393
394 /**
395 * @test
396 * @see DataSet/createPlaceholdersAndDeleteLiveParentPage.csv
397 */
398 public function createPlaceholdersAndDeleteLiveParentPage()
399 {
400 parent::createPlaceholdersAndDeleteLiveParentPage();
401 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
402 $this->assertAssertionDataSet('createPlaceholdersAndDeleteLiveParentPage');
403 }
404 }