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