[TASK] Streamline workspace DataHandler functional tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / Regular / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular;
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 abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
21 {
22 const VALUE_PageId = 89;
23 const VALUE_PageIdTarget = 90;
24 const VALUE_PageIdWebsite = 1;
25 const VALUE_ContentIdFirst = 297;
26 const VALUE_ContentIdSecond = 298;
27 const VALUE_ContentIdThird = 299;
28 const VALUE_ContentIdThirdLocalized = 300;
29 const VALUE_LanguageId = 1;
30 const VALUE_LanguageIdSecond = 2;
31
32 const TABLE_Page = 'pages';
33 const TABLE_PageOverlay = 'pages_language_overlay';
34 const TABLE_Content = 'tt_content';
35
36 /**
37 * @var string
38 */
39 protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Regular/DataSet/';
40
41 protected function setUp()
42 {
43 parent::setUp();
44 $this->importScenarioDataSet('LiveDefaultPages');
45 $this->importScenarioDataSet('LiveDefaultElements');
46
47 $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts']);
48 $this->backendUser->workspace = 0;
49 }
50
51 /**
52 * Content records
53 */
54
55 /**
56 * @see DataSet/createContentRecords.csv
57 */
58 public function createContents()
59 {
60 // Creating record at the beginning of the page
61 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
62 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][0];
63 // Creating record at the end of the page (after last one)
64 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, -self::VALUE_ContentIdSecond, ['header' => 'Testing #2']);
65 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][0];
66 }
67
68 /**
69 * Creation of a content element with language set to all
70 *
71 * @see DataSet/createContentForLanguageAll.csv
72 */
73 public function createContentForLanguageAll()
74 {
75 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Language set to all', 'sys_language_uid' => -1]);
76 $this->recordIds['newContentLanguageAll'] = $newTableIds[self::TABLE_Content][0];
77 }
78
79 /**
80 * @see DataSet/modifyContentRecord.csv
81 */
82 public function modifyContent()
83 {
84 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, ['header' => 'Testing #1']);
85 }
86
87 /**
88 * @see DataSet/deleteContentRecord.csv
89 */
90 public function deleteContent()
91 {
92 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
93 }
94
95 /**
96 * @see DataSet/deleteLocalizedContentNDeleteContent.csv
97 */
98 public function deleteLocalizedContentAndDeleteContent()
99 {
100 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized);
101 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdThird);
102 }
103
104 /**
105 * @see DataSet/copyContentRecord.csv
106 */
107 public function copyContent()
108 {
109 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageId);
110 $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
111 }
112
113 /**
114 * @see DataSet/copyContentToLanguage.csv
115 */
116 public function copyContentToLanguage()
117 {
118 $copiedTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_LanguageId);
119 $this->recordIds['localizedContentId'] = $copiedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
120 }
121
122 /**
123 * Free mode "translation" of a record in non default language
124 *
125 * @see DataSet/copyContentToLanguageFromNonDefaultLanguage.csv
126 */
127 public function copyContentToLanguageFromNonDefaultLanguage()
128 {
129 $copiedTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized, self::VALUE_LanguageIdSecond);
130 $this->recordIds['localizedContentId'] = $copiedTableIds[self::TABLE_Content][self::VALUE_ContentIdThirdLocalized];
131 }
132
133 /**
134 * @see DataSet/copyPasteContent.csv
135 */
136 public function copyPasteContent()
137 {
138 $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageId, ['header' => 'Testing #1']);
139 }
140
141 /**
142 * @see DataSet/localizeContentRecord.csv
143 */
144 public function localizeContent()
145 {
146 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_LanguageId);
147 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
148 }
149
150 public function localizeContentWithLanguageSynchronization()
151 {
152 $GLOBALS['TCA']['tt_content']['columns']['header']['config']['behaviour']['allowLanguageSynchronization'] = true;
153 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_LanguageId);
154 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
155 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, ['header' => 'Testing #1']);
156 }
157
158 public function localizeContentWithLanguageSynchronizationHavingNullValue()
159 {
160 $GLOBALS['TCA']['tt_content']['columns']['bodytext']['config']['eval'] = 'null';
161 $GLOBALS['TCA']['tt_content']['columns']['bodytext']['config']['behaviour']['allowLanguageSynchronization'] = true;
162 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, ['bodytext' => null]);
163 self::localizeContentWithLanguageSynchronization();
164 }
165
166 /**
167 * @see DataSet/localizeContentFromNonDefaultLanguage.csv
168 */
169 public function localizeContentFromNonDefaultLanguage()
170 {
171 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized, self::VALUE_LanguageIdSecond);
172 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdThirdLocalized];
173 }
174
175 public function localizeContentFromNonDefaultLanguageWithLanguageSynchronizationDefault()
176 {
177 $GLOBALS['TCA']['tt_content']['columns']['header']['config']['behaviour']['allowLanguageSynchronization'] = true;
178 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized, self::VALUE_LanguageIdSecond);
179 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdThirdLocalized];
180 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdThird, ['header' => 'Testing #1']);
181 }
182
183 public function localizeContentFromNonDefaultLanguageWithLanguageSynchronizationSource()
184 {
185 $GLOBALS['TCA']['tt_content']['columns']['header']['config']['behaviour']['allowLanguageSynchronization'] = true;
186 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized, self::VALUE_LanguageIdSecond);
187 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdThirdLocalized];
188 $this->actionService->modifyRecord(self::TABLE_Content, $this->recordIds['localizedContentId'], ['l10n_state' => ['header' => 'source']]);
189 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdThird, ['header' => 'Testing #1']);
190 }
191
192 /**
193 * @see DataSet/changeContentRecordSorting.csv
194 */
195 public function changeContentSorting()
196 {
197 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
198 }
199
200 /**
201 * @see DataSet/moveContentRecordToDifferentPage.csv
202 */
203 public function moveContentToDifferentPage()
204 {
205 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
206 }
207
208 /**
209 * @see DataSet/movePasteContentToDifferentPage.csv
210 */
211 public function movePasteContentToDifferentPage()
212 {
213 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget, ['header' => 'Testing #1']);
214 }
215
216 /**
217 * @see DataSet/moveContentRecordToDifferentPageAndChangeSorting.csv
218 */
219 public function moveContentToDifferentPageAndChangeSorting()
220 {
221 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
222 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
223 }
224
225 /**
226 * Page records
227 */
228
229 /**
230 * @see DataSet/createPageRecord.csv
231 */
232 public function createPage()
233 {
234 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
235 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
236 }
237
238 /**
239 * @see DataSet/modifyPageRecord.csv
240 */
241 public function modifyPage()
242 {
243 $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1']);
244 }
245
246 /**
247 * @see DataSet/deletePageRecord.csv
248 */
249 public function deletePage()
250 {
251 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
252 }
253
254 /**
255 * @see DataSet/copyPage.csv
256 */
257 public function copyPage()
258 {
259 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
260 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
261 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
262 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
263 }
264
265 /**
266 * @see DataSet/copyPageFreeMode.csv
267 */
268 public function copyPageFreeMode()
269 {
270 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdTarget);
271 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageIdTarget];
272 }
273
274 /**
275 * @see DataSet/localizePageRecord.csv
276 */
277 public function localizePage()
278 {
279 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
280 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
281 $this->recordIds['localizedPageOverlayId'] = $localizedTableIds[self::TABLE_PageOverlay][self::VALUE_PageId];
282 }
283
284 public function localizePageWithLanguageSynchronization()
285 {
286 $GLOBALS['TCA']['pages_language_overlay']['columns']['title']['config']['behaviour']['allowLanguageSynchronization'] = true;
287 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
288 $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
289 $this->recordIds['localizedPageOverlayId'] = $localizedTableIds[self::TABLE_PageOverlay][self::VALUE_PageId];
290 $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1']);
291 }
292
293 /**
294 * @see DataSet/changePageRecordSorting.csv
295 */
296 public function changePageSorting()
297 {
298 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
299 }
300
301 /**
302 * @see DataSet/movePageRecordToDifferentPage.csv
303 */
304 public function movePageToDifferentPage()
305 {
306 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
307 }
308
309 /**
310 * @see DataSet/movePageRecordToDifferentPageAndChangeSorting.csv
311 */
312 public function movePageToDifferentPageAndChangeSorting()
313 {
314 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
315 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
316 }
317 }