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