[BUGFIX] Failing cascaded delete action of localized elements
[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 require_once dirname(dirname(__FILE__)) . '/AbstractActionTestCase.php';
18
19 /**
20 * Functional test for the DataHandler
21 */
22 class ActionTest extends \TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Regular\AbstractActionTestCase {
23
24 /**
25 * @var string
26 */
27 protected $assertionDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/Publish/DataSet/';
28
29 /**
30 * Content records
31 */
32
33 /**
34 * @test
35 * @see DataSet/Assertion/createContentRecords.csv
36 */
37 public function createContents() {
38 parent::createContents();
39 $this->actionService->publishRecords(
40 array(
41 self::TABLE_Content => array($this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']),
42 )
43 );
44 $this->assertAssertionDataSet('createContents');
45
46 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
47 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
48 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1', 'Testing #2'));
49 }
50
51 /**
52 * @test
53 * @see DataSet/Assertion/createContentRecordAndDiscardCreatedContentRecord.csv
54 */
55 public function createContentAndDiscardCreatedContent() {
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 parent::createAndCopyContentAndDiscardCopiedContent();
72 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
73 // Actually this is not required, since there's nothing to publish... but it's a test case!
74 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId'], FALSE);
75 $this->assertAssertionDataSet('createNCopyContentNDiscardCopiedContent');
76
77 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
78 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
79 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
80 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
81 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1 (copy 1)'));
82 }
83
84 /**
85 * @test
86 * @see DataSet/Assertion/modifyContentRecord.csv
87 */
88 public function modifyContent() {
89 parent::modifyContent();
90 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
91 $this->assertAssertionDataSet('modifyContent');
92
93 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
94 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
95 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
96 }
97
98 /**
99 * @test
100 * @see DataSet/Assertion/deleteContentRecord.csv
101 */
102 public function deleteContent() {
103 parent::deleteContent();
104 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
105 $this->assertAssertionDataSet('deleteContent');
106
107 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
108 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
109 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
110 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
111 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
112 }
113
114 /**
115 * @test
116 * @see DataSet/deleteLocalizedContentNDeleteContent.csv
117 */
118 public function deleteLocalizedContentAndDeleteContent() {
119 parent::deleteLocalizedContentAndDeleteContent();
120 $this->actionService->publishRecords(
121 array(
122 self::TABLE_Content => array(self::VALUE_ContentIdThird, self::VALUE_ContentIdThirdLocalized),
123 )
124 );
125 $this->assertAssertionDataSet('deleteLocalizedContentNDeleteContent');
126
127 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
128 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
129 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #3', '[Translate to Dansk:] Regular Element #3'));
130 }
131
132 /**
133 * @test
134 * @see DataSet/Assertion/copyContentRecord.csv
135 */
136 public function copyContent() {
137 parent::copyContent();
138 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
139 $this->assertAssertionDataSet('copyContent');
140
141 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
142 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
143 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
144 }
145
146 /**
147 * @test
148 * @see DataSet/Assertion/localizeContentRecord.csv
149 */
150 public function localizeContent() {
151 parent::localizeContent();
152 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
153 $this->assertAssertionDataSet('localizeContent');
154
155 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
156 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
157 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
158 }
159
160 /**
161 * @test
162 * @see DataSet/Assertion/changeContentRecordSorting.csv
163 */
164 public function changeContentSorting() {
165 parent::changeContentSorting();
166 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
167 $this->assertAssertionDataSet('changeContentSorting');
168
169 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
170 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
171 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
172 }
173
174 /**
175 * @test
176 * @see DataSet/Assertion/moveContentRecordToDifferentPage.csv
177 */
178 public function moveContentToDifferentPage() {
179 parent::moveContentToDifferentPage();
180 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
181 $this->assertAssertionDataSet('moveContentToDifferentPage');
182
183 $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
184 $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
185 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
186 $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
187 $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
188 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
189 }
190
191 /**
192 * @test
193 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
194 */
195 public function moveContentToDifferentPageAndChangeSorting() {
196 parent::moveContentToDifferentPageAndChangeSorting();
197 $this->actionService->publishRecords(
198 array(
199 self::TABLE_Content => array(self::VALUE_ContentIdFirst, self::VALUE_ContentIdSecond),
200 )
201 );
202 $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
203
204 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
205 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
206 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
207 }
208
209 /**
210 * Page records
211 */
212
213 /**
214 * @test
215 * @see DataSet/Assertion/createPageRecord.csv
216 */
217 public function createPage() {
218 parent::createPage();
219 $this->actionService->publishRecord(self::TABLE_Page, $this->recordIds['newPageId']);
220 $this->assertAssertionDataSet('createPage');
221
222 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
223 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
224 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
225 }
226
227 /**
228 * @test
229 * @see DataSet/Assertion/modifyPageRecord.csv
230 */
231 public function modifyPage() {
232 parent::modifyPage();
233 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
234 $this->assertAssertionDataSet('modifyPage');
235
236 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
237 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
238 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
239 }
240
241 /**
242 * @test
243 * @see DataSet/Assertion/deletePageRecord.csv
244 */
245 public function deletePage() {
246 parent::deletePage();
247 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
248 $this->assertAssertionDataSet('deletePage');
249
250 $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, FALSE);
251 $this->assertContains('PageNotFoundException', $response->getError());
252 }
253
254 /**
255 * @test
256 * @see DataSet/Assertion/copyPageRecord.csv
257 */
258 public function copyPage() {
259 parent::copyPage();
260 $this->actionService->publishRecords(
261 array(
262 self::TABLE_Page => array($this->recordIds['newPageId']),
263 self::TABLE_Content => array($this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']),
264 )
265 );
266 $this->assertAssertionDataSet('copyPage');
267
268 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
269 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
270 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
271 }
272
273 /**
274 * @test
275 * @see DataSet/Assertion/localizePageRecord.csv
276 */
277 public function localizePage() {
278 parent::localizePage();
279 $this->actionService->publishRecord(self::TABLE_PageOverlay, $this->recordIds['localizedPageOverlayId']);
280 $this->assertAssertionDataSet('localizePage');
281
282 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
283 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
284 ->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
285 }
286
287 /**
288 * @test
289 * @see DataSet/Assertion/changePageRecordSorting.csv
290 */
291 public function changePageSorting() {
292 parent::changePageSorting();
293 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
294 $this->assertAssertionDataSet('changePageSorting');
295
296 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
297 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
298 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
299 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
300 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
301 }
302
303 /**
304 * @test
305 * @see DataSet/Assertion/movePageRecordToDifferentPage.csv
306 */
307 public function movePageToDifferentPage() {
308 parent::movePageToDifferentPage();
309 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
310 $this->assertAssertionDataSet('movePageToDifferentPage');
311
312 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
313 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
314 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
315 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
316 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
317 }
318
319 /**
320 * @test
321 * @see DataSet/Assertion/movePageRecordToDifferentPageAndChangeSorting.csv
322 */
323 public function movePageToDifferentPageAndChangeSorting() {
324 parent::movePageToDifferentPageAndChangeSorting();
325 $this->actionService->publishRecords(
326 array(
327 self::TABLE_Page => array(self::VALUE_PageId, self::VALUE_PageIdTarget),
328 )
329 );
330 $this->assertAssertionDataSet('movePageToDifferentPageNChangeSorting');
331
332 $responseSectionsPage = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
333 $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
334 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
335 $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
336 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
337 $responseSectionsWebsite = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
338 $this->assertThat($responseSectionsWebsite, $this->getRequestSectionStructureHasRecordConstraint()
339 ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
340 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Relations', 'DataHandlerTest'));
341 }
342
343 /**
344 * @test
345 * @see DataSet/Assertion/movePageRecordToDifferentPageAndCreatePageRecordAfterMovedPageRecord.csv
346 * @see http://forge.typo3.org/issues/33104
347 * @see http://forge.typo3.org/issues/55573
348 */
349 public function movePageToDifferentPageAndCreatePageAfterMovedPage() {
350 parent::movePageToDifferentPageAndCreatePageAfterMovedPage();
351 $this->actionService->publishRecords(
352 array(
353 self::TABLE_Page => array(self::VALUE_PageIdTarget, $this->recordIds['newPageId']),
354 )
355 );
356 $this->assertAssertionDataSet('movePageToDifferentPageNCreatePageAfterMovedPage');
357
358 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
359 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
360 ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
361 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Testing #1', 'DataHandlerTest'));
362 }
363
364 }