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