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