39351271636d0ec553d17616a4d278a487628ec9
[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 $this->markTestSkipped('see http://forge.typo3.org/issues/59113');
120 parent::deleteLocalizedContentAndDeleteContent();
121 $this->actionService->publishRecords(
122 array(
123 self::TABLE_Content => array(self::VALUE_ContentIdThird, self::VALUE_ContentIdThirdLocalized),
124 )
125 );
126 $this->assertAssertionDataSet('deleteLocalizedContentNDeleteContent');
127
128 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
129 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
130 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #3', '[Translate to Dansk:] Regular Element #3'));
131 }
132
133 /**
134 * @test
135 * @see DataSet/Assertion/copyContentRecord.csv
136 */
137 public function copyContent() {
138 parent::copyContent();
139 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
140 $this->assertAssertionDataSet('copyContent');
141
142 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
143 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
144 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
145 }
146
147 /**
148 * @test
149 * @see DataSet/Assertion/localizeContentRecord.csv
150 */
151 public function localizeContent() {
152 parent::localizeContent();
153 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
154 $this->assertAssertionDataSet('localizeContent');
155
156 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
157 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
158 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
159 }
160
161 /**
162 * @test
163 * @see DataSet/Assertion/changeContentRecordSorting.csv
164 */
165 public function changeContentSorting() {
166 parent::changeContentSorting();
167 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
168 $this->assertAssertionDataSet('changeContentSorting');
169
170 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
171 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
172 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
173 }
174
175 /**
176 * @test
177 * @see DataSet/Assertion/moveContentRecordToDifferentPage.csv
178 */
179 public function moveContentToDifferentPage() {
180 parent::moveContentToDifferentPage();
181 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
182 $this->assertAssertionDataSet('moveContentToDifferentPage');
183
184 $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
185 $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
186 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
187 $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
188 $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
189 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
190 }
191
192 /**
193 * @test
194 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
195 */
196 public function moveContentToDifferentPageAndChangeSorting() {
197 parent::moveContentToDifferentPageAndChangeSorting();
198 $this->actionService->publishRecords(
199 array(
200 self::TABLE_Content => array(self::VALUE_ContentIdFirst, self::VALUE_ContentIdSecond),
201 )
202 );
203 $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
204
205 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
206 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
207 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
208 }
209
210 /**
211 * Page records
212 */
213
214 /**
215 * @test
216 * @see DataSet/Assertion/createPageRecord.csv
217 */
218 public function createPage() {
219 parent::createPage();
220 $this->actionService->publishRecord(self::TABLE_Page, $this->recordIds['newPageId']);
221 $this->assertAssertionDataSet('createPage');
222
223 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
224 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
225 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
226 }
227
228 /**
229 * @test
230 * @see DataSet/Assertion/modifyPageRecord.csv
231 */
232 public function modifyPage() {
233 parent::modifyPage();
234 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
235 $this->assertAssertionDataSet('modifyPage');
236
237 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
238 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
239 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
240 }
241
242 /**
243 * @test
244 * @see DataSet/Assertion/deletePageRecord.csv
245 */
246 public function deletePage() {
247 parent::deletePage();
248 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
249 $this->assertAssertionDataSet('deletePage');
250
251 $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, FALSE);
252 $this->assertContains('PageNotFoundException', $response->getError());
253 }
254
255 /**
256 * @test
257 * @see DataSet/Assertion/copyPageRecord.csv
258 */
259 public function copyPage() {
260 parent::copyPage();
261 $this->actionService->publishRecords(
262 array(
263 self::TABLE_Page => array($this->recordIds['newPageId']),
264 self::TABLE_Content => array($this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']),
265 )
266 );
267 $this->assertAssertionDataSet('copyPage');
268
269 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
270 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
271 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
272 }
273
274 /**
275 * @test
276 * @see DataSet/Assertion/localizePageRecord.csv
277 */
278 public function localizePage() {
279 parent::localizePage();
280 $this->actionService->publishRecord(self::TABLE_PageOverlay, $this->recordIds['localizedPageOverlayId']);
281 $this->assertAssertionDataSet('localizePage');
282
283 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
284 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
285 ->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
286 }
287
288 /**
289 * @test
290 * @see DataSet/Assertion/changePageRecordSorting.csv
291 */
292 public function changePageSorting() {
293 parent::changePageSorting();
294 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
295 $this->assertAssertionDataSet('changePageSorting');
296
297 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
298 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
299 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
300 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
301 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
302 }
303
304 /**
305 * @test
306 * @see DataSet/Assertion/movePageRecordToDifferentPage.csv
307 */
308 public function movePageToDifferentPage() {
309 parent::movePageToDifferentPage();
310 $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
311 $this->assertAssertionDataSet('movePageToDifferentPage');
312
313 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
314 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
315 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
316 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
317 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
318 }
319
320 /**
321 * @test
322 * @see DataSet/Assertion/movePageRecordToDifferentPageAndChangeSorting.csv
323 */
324 public function movePageToDifferentPageAndChangeSorting() {
325 parent::movePageToDifferentPageAndChangeSorting();
326 $this->actionService->publishRecords(
327 array(
328 self::TABLE_Page => array(self::VALUE_PageId, self::VALUE_PageIdTarget),
329 )
330 );
331 $this->assertAssertionDataSet('movePageToDifferentPageNChangeSorting');
332
333 $responseSectionsPage = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
334 $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
335 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
336 $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
337 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
338 $responseSectionsWebsite = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
339 $this->assertThat($responseSectionsWebsite, $this->getRequestSectionStructureHasRecordConstraint()
340 ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
341 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Relations', 'DataHandlerTest'));
342 }
343
344 /**
345 * @test
346 * @see DataSet/Assertion/movePageRecordToDifferentPageAndCreatePageRecordAfterMovedPageRecord.csv
347 * @see http://forge.typo3.org/issues/33104
348 * @see http://forge.typo3.org/issues/55573
349 */
350 public function movePageToDifferentPageAndCreatePageAfterMovedPage() {
351 parent::movePageToDifferentPageAndCreatePageAfterMovedPage();
352 $this->actionService->publishRecords(
353 array(
354 self::TABLE_Page => array(self::VALUE_PageIdTarget, $this->recordIds['newPageId']),
355 )
356 );
357 $this->assertAssertionDataSet('movePageToDifferentPageNCreatePageAfterMovedPage');
358
359 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
360 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
361 ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
362 ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Testing #1', 'DataHandlerTest'));
363 }
364
365 }