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