6a4b0c13c7617df6ebd69527e7d0a8f72086aab3
[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/copyPageRecord.csv
269 */
270 public function copyPage()
271 {
272 parent::copyPage();
273 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
274 $this->assertAssertionDataSet('copyPage');
275
276 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
277 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
278 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
279 }
280
281 /**
282 * @test
283 * @see DataSet/Assertion/localizePageRecord.csv
284 */
285 public function localizePage()
286 {
287 parent::localizePage();
288 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
289 $this->assertAssertionDataSet('localizePage');
290
291 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
292 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
293 ->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
294 }
295
296 /**
297 * @test
298 * @see DataSet/Assertion/changePageRecordSorting.csv
299 */
300 public function changePageSorting()
301 {
302 parent::changePageSorting();
303 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
304 $this->assertAssertionDataSet('changePageSorting');
305
306 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
307 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
308 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
309 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
310 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
311 }
312
313 /**
314 * @test
315 * @see DataSet/Assertion/movePageRecordToDifferentPage.csv
316 */
317 public function movePageToDifferentPage()
318 {
319 parent::movePageToDifferentPage();
320 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
321 $this->assertAssertionDataSet('movePageToDifferentPage');
322
323 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
324 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
325 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
326 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
327 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
328 }
329
330 /**
331 * @test
332 * @see DataSet/Assertion/movePageRecordToDifferentPageAndChangeSorting.csv
333 */
334 public function movePageToDifferentPageAndChangeSorting()
335 {
336 parent::movePageToDifferentPageAndChangeSorting();
337 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
338 $this->assertAssertionDataSet('movePageToDifferentPageNChangeSorting');
339
340 $responseSectionsPage = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
341 $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
342 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
343 $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
344 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
345 $responseSectionsWebsite = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
346 $this->assertThat($responseSectionsWebsite, $this->getRequestSectionStructureHasRecordConstraint()
347 ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
348 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Relations', 'DataHandlerTest'));
349 }
350
351 /**
352 * @test
353 * @see DataSet/Assertion/movePageRecordToDifferentPageAndCreatePageRecordAfterMovedPageRecord.csv
354 * @see http://forge.typo3.org/issues/33104
355 * @see http://forge.typo3.org/issues/55573
356 */
357 public function movePageToDifferentPageAndCreatePageAfterMovedPage()
358 {
359 parent::movePageToDifferentPageAndCreatePageAfterMovedPage();
360 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
361 $this->assertAssertionDataSet('movePageToDifferentPageNCreatePageAfterMovedPage');
362
363 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
364 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
365 ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
366 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Testing #1', 'DataHandlerTest'));
367 }
368
369 /**
370 * @test
371 * @see DataSet/createPlaceholdersAndDeleteDraftParentPage.csv
372 */
373 public function createPlaceholdersAndDeleteDraftParentPage()
374 {
375 // @todo These two log entries could be avoided in DataHandlerHook, but are expected
376 // "[newlog()] Error: You cannot swap versions for a record you do not have access to edit!"
377 $this->expectedErrorLogEntries = 2;
378
379 parent::createPlaceholdersAndDeleteDraftParentPage();
380 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
381 $this->assertAssertionDataSet('createPlaceholdersAndDeleteDraftParentPage');
382 }
383
384 /**
385 * @test
386 * @see DataSet/createPlaceholdersAndDeleteLiveParentPage.csv
387 */
388 public function createPlaceholdersAndDeleteLiveParentPage()
389 {
390 parent::createPlaceholdersAndDeleteLiveParentPage();
391 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
392 $this->assertAssertionDataSet('createPlaceholdersAndDeleteLiveParentPage');
393 }
394 }