[CLEANUP] Remove obsolete require_once from test files
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / IRRE / ForeignField / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\IRRE\ForeignField;
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_ContentIdLast = 298;
27 const VALUE_HotelIdFirst = 3;
28 const VALUE_HotelIdSecond = 4;
29 const VALUE_HotelIdThird = 5;
30 const VALUE_LanguageId = 1;
31
32 const TABLE_Page = 'pages';
33 const TABLE_Content = 'tt_content';
34 const TABLE_Hotel = 'tx_irretutorial_1nff_hotel';
35 const TABLE_Offer = 'tx_irretutorial_1nff_offer';
36
37 const FIELD_ContentHotel = 'tx_irretutorial_1nff_hotels';
38 const FIELD_HotelOffer = 'offers';
39
40 /**
41 * @var string
42 */
43 protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/IRRE/ForeignField/DataSet/';
44
45 protected function setUp() {
46 parent::setUp();
47 $this->importScenarioDataSet('LiveDefaultPages');
48 $this->importScenarioDataSet('LiveDefaultElements');
49
50 $this->setUpFrontendRootPage(
51 1,
52 array(
53 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
54 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/ExtbaseJsonRenderer.ts',
55 )
56 );
57 $this->backendUser->workspace = 0;
58 }
59
60 /**
61 * Parent content records
62 */
63
64 /**
65 * @see DataSet/Assertion/createParentContentRecord.csv
66 */
67 public function createParentContent() {
68 $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
69 }
70
71 /**
72 * @see DataSet/Assertion/modifyParentContentRecord.csv
73 */
74 public function modifyParentContent() {
75 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, array('header' => 'Testing #1'));
76 }
77
78 /**
79 * @see DataSet/Assertion/deleteParentContentRecord.csv
80 */
81 public function deleteParentContent() {
82 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
83 }
84
85 /**
86 * @see DataSet/Assertion/copyParentContentRecord.csv
87 */
88 public function copyParentContent() {
89 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
90 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
91 }
92
93 /**
94 * @see DataSet/copyParentContentToDifferentPage.csv
95 */
96 public function copyParentContentToDifferentPage() {
97 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
98 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
99 }
100
101 /**
102 * @see DataSet/localizeParentContentKeep.csv
103 */
104 public function localizeParentContentInKeepMode() {
105 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
106 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = FALSE;
107 $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = FALSE;
108 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
109 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
110 }
111
112 /**
113 * @see DataSet/localizeParentContentWAllChildrenKeep.csv
114 */
115 public function localizeParentContentWithAllChildrenInKeepMode() {
116 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'keep';
117 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = TRUE;
118 $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = TRUE;
119 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
120 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
121 }
122
123 /**
124 * @see DataSet/localizeParentContentSelect.csv
125 */
126 public function localizeParentContentInSelectMode() {
127 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
128 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = FALSE;
129 $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = FALSE;
130 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
131 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
132 }
133
134 /**
135 * @see DataSet/localizeParentContentWAllChildrenSelect.csv
136 */
137 public function localizeParentContentWithAllChildrenInSelectMode() {
138 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizationMode'] = 'select';
139 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_ContentHotel]['config']['behaviour']['localizeChildrenAtParentLocalization'] = TRUE;
140 $GLOBALS['TCA'][self::TABLE_Hotel]['columns'][self::FIELD_HotelOffer]['config']['behaviour']['localizeChildrenAtParentLocalization'] = TRUE;
141 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
142 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
143 }
144
145 /**
146 * @see DataSet/Assertion/changeParentContentRecordSorting.csv
147 */
148 public function changeParentContentSorting() {
149 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
150 }
151
152 /**
153 * @see DataSet/Assertion/moveParentContentRecordToDifferentPage.csv
154 */
155 public function moveParentContentToDifferentPage() {
156 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
157 }
158
159 /**
160 * @see DataSet/Assertion/moveParentContentRecordToDifferentPageAndChangeSorting.csv
161 */
162 public function moveParentContentToDifferentPageAndChangeSorting() {
163 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
164 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
165 }
166
167 /**
168 * Page records
169 */
170
171 /**
172 * @see DataSet/Assertion/modifyPageRecord.csv
173 */
174 public function modifyPage() {
175 $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1'));
176 }
177
178 /**
179 * @see DataSet/Assertion/deletePageRecord.csv
180 */
181 public function deletePage() {
182 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
183 }
184
185 /**
186 * @see DataSet/Assertion/copyPageRecord.csv
187 */
188 public function copyPage() {
189 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
190 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
191 }
192
193 /**
194 * @see DataSet/Assertion/copyPageWHotelBeforeParentContent.csv
195 */
196 public function copyPageWithHotelBeforeParentContent() {
197 // Ensure hotels get processed first
198 $GLOBALS['TCA'] = array_merge(
199 array(self::TABLE_Hotel => $GLOBALS['TCA'][self::TABLE_Hotel]),
200 $GLOBALS['TCA']
201 );
202
203 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
204 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
205 }
206
207 /**
208 * IRRE Child Records
209 */
210
211 /**
212 * @see DataSet/Assertion/createParentContentRecordWithHotelAndOfferChildRecords.csv
213 */
214 public function createParentContentWithHotelAndOfferChildren() {
215 $newTableIds = $this->actionService->createNewRecords(
216 self::VALUE_PageId,
217 array(
218 self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
219 self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
220 self::TABLE_Offer => array('title' => 'Offer #1'),
221 )
222 );
223 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
224 }
225
226 /**
227 * @see DataSet/Assertion/createAndCopyParentContentRecordWithHotelAndOfferChildRecords.csv
228 */
229 public function createAndCopyParentContentWithHotelAndOfferChildren() {
230 $newTableIds = $this->actionService->createNewRecords(
231 self::VALUE_PageId,
232 array(
233 self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
234 self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
235 self::TABLE_Offer => array('title' => 'Offer #1'),
236 )
237 );
238 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
239 $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
240 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
241 $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
242 $this->recordIds['copiedHotelId'] = $copiedTableIds[self::TABLE_Hotel][$this->recordIds['newHotelId']];
243 }
244
245 /**
246 * @see DataSet/Assertion/createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords.csv
247 */
248 public function createAndLocalizeParentContentWithHotelAndOfferChildren() {
249 $newTableIds = $this->actionService->createNewRecords(
250 self::VALUE_PageId,
251 array(
252 self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentHotel => '__nextUid'),
253 self::TABLE_Hotel => array('title' => 'Hotel #1', self::FIELD_HotelOffer => '__nextUid'),
254 self::TABLE_Offer => array('title' => 'Offer #1'),
255 )
256 );
257 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
258 $this->recordIds['newHotelId'] = $newTableIds[self::TABLE_Hotel][0];
259 $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
260 }
261
262 /**
263 * @see DataSet/Assertion/modifyOnlyHotelChildRecord.csv
264 */
265 public function modifyOnlyHotelChild() {
266 $this->actionService->modifyRecord(self::TABLE_Hotel, 4, array('title' => 'Testing #1'));
267 }
268
269 /**
270 * @see DataSet/Assertion/modifyParentRecordAndChangeHotelChildRecordsSorting.csv
271 */
272 public function modifyParentAndChangeHotelChildrenSorting() {
273 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array(self::FIELD_ContentHotel => '4,3'));
274 }
275
276 /**
277 * @see DataSet/Assertion/modifyParentRecordWithHotelChildRecord.csv
278 */
279 public function modifyParentWithHotelChild() {
280 $this->actionService->modifyRecords(
281 self::VALUE_PageId,
282 array(
283 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, self::FIELD_ContentHotel => '3,4'),
284 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
285 )
286 );
287 }
288
289 /**
290 * @see DataSet/Assertion/modifyParentRecordAndAddHotelChildRecord.csv
291 */
292 public function modifyParentAndAddHotelChild() {
293 $this->actionService->modifyRecords(
294 self::VALUE_PageId,
295 array(
296 self::TABLE_Content => array('uid' => self::VALUE_ContentIdLast, self::FIELD_ContentHotel => '5,__nextUid'),
297 self::TABLE_Hotel => array('uid' => '__NEW', 'title' => 'Hotel #2'),
298 )
299 );
300 }
301
302 /**
303 * @see DataSet/Assertion/modifyParentRecordAndDeleteHotelChildRecord.csv
304 */
305 public function modifyParentAndDeleteHotelChild() {
306 $this->actionService->modifyRecord(
307 self::TABLE_Content,
308 self::VALUE_ContentIdFirst,
309 array(self::FIELD_ContentHotel => '3'),
310 array(self::TABLE_Hotel => array(4))
311 );
312 }
313
314 }