4ac52e01b0a11ec370d413987c1463775ce592cb
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / Group / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Group;
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_ContentIdFirst = 297;
25 const VALUE_ContentIdLast = 298;
26 const VALUE_LanguageId = 1;
27 const VALUE_LanguageIdSecond = 2;
28 const VALUE_ElementIdFirst = 1;
29 const VALUE_ElementIdSecond = 2;
30 const VALUE_ElementIdThird = 3;
31
32 const TABLE_Content = 'tt_content';
33 const TABLE_Element = 'tx_testdatahandler_element';
34
35 const FIELD_ContentElement = 'tx_testdatahandler_group';
36
37 /**
38 * @var string
39 */
40 protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Group/DataSet/';
41
42 protected function setUp()
43 {
44 $this->testExtensionsToLoad[] = 'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_datahandler';
45
46 parent::setUp();
47 $this->importScenarioDataSet('LiveDefaultPages');
48 $this->importScenarioDataSet('LiveDefaultElements');
49 $this->importScenarioDataSet('ReferenceIndex');
50
51 $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
52 }
53
54 /**
55 * Relations
56 */
57
58 /**
59 * @test
60 * @see DataSet/addElementRelation.csv
61 */
62 public function addElementRelation()
63 {
64 $this->actionService->modifyReferences(
65 self::TABLE_Content,
66 self::VALUE_ContentIdFirst,
67 self::FIELD_ContentElement,
68 [self::VALUE_ElementIdFirst, self::VALUE_ElementIdSecond, self::VALUE_ElementIdThird]
69 );
70 }
71
72 /**
73 * @test
74 * @see DataSet/deleteElementRelation.csv
75 */
76 public function deleteElementRelation()
77 {
78 $this->actionService->modifyReferences(
79 self::TABLE_Content,
80 self::VALUE_ContentIdFirst,
81 self::FIELD_ContentElement,
82 [self::VALUE_ElementIdFirst]
83 );
84 }
85
86 /**
87 * @test
88 * @see DataSet/changeElementSorting.csv
89 */
90 public function changeElementSorting()
91 {
92 $this->actionService->moveRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, -self::VALUE_ElementIdSecond);
93 }
94
95 /**
96 * @test
97 * @see DataSet/changeElementRelationSorting.csv
98 */
99 public function changeElementRelationSorting()
100 {
101 $this->actionService->modifyReferences(
102 self::TABLE_Content,
103 self::VALUE_ContentIdFirst,
104 self::FIELD_ContentElement,
105 [self::VALUE_ElementIdSecond, self::VALUE_ElementIdFirst]
106 );
107 }
108
109 /**
110 * @test
111 * @see DataSet/createContentNAddRelation.csv
112 */
113 public function createContentAndAddElementRelation()
114 {
115 $newTableIds = $this->actionService->createNewRecord(
116 self::TABLE_Content,
117 self::VALUE_PageId,
118 ['header' => 'Testing #1', self::FIELD_ContentElement => self::VALUE_ElementIdFirst]
119 );
120 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
121 }
122
123 /**
124 * @test
125 * @see DataSet/createContentNCreateRelation.csv
126 */
127 public function createContentAndCreateElementRelation()
128 {
129 $newElementIds = $this->actionService->createNewRecord(self::TABLE_Element, self::VALUE_PageId, ['title' => 'Testing #1']);
130 $this->recordIds['newElementId'] = $newElementIds[self::TABLE_Element][0];
131 // It's not possible to use "NEW..." values for the TCA type 'group'
132 $newContentIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1', self::FIELD_ContentElement => $this->recordIds['newElementId']]);
133 $this->recordIds['newContentId'] = $newContentIds[self::TABLE_Content][0];
134 }
135
136 /**
137 * @test
138 * @see DataSet/modifyElementOfRelation.csv
139 */
140 public function modifyElementOfRelation()
141 {
142 $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, ['title' => 'Testing #1']);
143 }
144
145 /**
146 * @test
147 * @see DataSet/modifyContentOfRelation.csv
148 */
149 public function modifyContentOfRelation()
150 {
151 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
152 }
153
154 /**
155 * @test
156 * @see DataSet/modifyBothSidesOfRelation.csv
157 */
158 public function modifyBothSidesOfRelation()
159 {
160 $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, ['title' => 'Testing #1']);
161 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
162 }
163
164 /**
165 * @test
166 * @see DataSet/deleteContentOfRelation.csv
167 */
168 public function deleteContentOfRelation()
169 {
170 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
171 }
172
173 /**
174 * @test
175 * @see DataSet/deleteElementOfRelation.csv
176 */
177 public function deleteElementOfRelation()
178 {
179 $this->actionService->deleteRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
180 }
181
182 /**
183 * @test
184 * @see DataSet/copyContentOfRelation.csv
185 */
186 public function copyContentOfRelation()
187 {
188 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
189 $this->recordIds['copiedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
190 }
191
192 /**
193 * @test
194 * @see DataSet/copyElementOfRelation.csv
195 */
196 public function copyElementOfRelation()
197 {
198 $newTableIds = $this->actionService->copyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_PageId);
199 $this->recordIds['copiedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
200 }
201
202 /**
203 * @test
204 * @see DataSet/copyContentToLanguageOfRelation.csv
205 */
206 public function copyContentToLanguageOfRelation()
207 {
208 $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
209 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
210 }
211
212 /**
213 * @test
214 * @see DataSet/copyElementToLanguageOfRelation.csv
215 */
216 public function copyElementToLanguageOfRelation()
217 {
218 $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
219 $this->recordIds['localizedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
220 }
221
222 /**
223 * @test
224 * @see DataSet/localizeContentOfRelation.csv
225 */
226 public function localizeContentOfRelation()
227 {
228 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
229 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
230 }
231
232 public function localizeContentOfRelationWithLanguageSynchronization()
233 {
234 $GLOBALS['TCA']['tt_content']['columns'][self::FIELD_ContentElement]['config']['behaviour']['allowLanguageSynchronization'] = true;
235 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
236 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
237 $this->actionService->modifyReferences(
238 self::TABLE_Content,
239 self::VALUE_ContentIdLast,
240 self::FIELD_ContentElement,
241 [self::VALUE_ElementIdFirst, self::VALUE_ElementIdSecond]
242 );
243 }
244
245 public function localizeContentChainOfRelationWithLanguageSynchronizationSource()
246 {
247 $GLOBALS['TCA']['tt_content']['columns'][self::FIELD_ContentElement]['config']['behaviour']['allowLanguageSynchronization'] = true;
248 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
249 $this->recordIds['localizedContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
250 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['localizedContentIdFirst'], self::VALUE_LanguageIdSecond);
251 $this->recordIds['localizedContentIdSecond'] = $newTableIds[self::TABLE_Content][$this->recordIds['localizedContentIdFirst']];
252 $this->actionService->modifyRecord(
253 self::TABLE_Content,
254 $this->recordIds['localizedContentIdSecond'],
255 ['l10n_state' => [self::FIELD_ContentElement => 'source']]
256 );
257 $this->actionService->modifyReferences(
258 self::TABLE_Content,
259 self::VALUE_ContentIdLast,
260 self::FIELD_ContentElement,
261 [self::VALUE_ElementIdFirst, self::VALUE_ElementIdSecond]
262 );
263 }
264
265 /**
266 * @test
267 * @see DataSet/localizeElementOfRelation.csv
268 */
269 public function localizeElementOfRelation()
270 {
271 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
272 $this->recordIds['localizedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
273 }
274
275 /**
276 * @test
277 * @see DataSet/moveContentOfRelationToDifferentPage.csv
278 */
279 public function moveContentOfRelationToDifferentPage()
280 {
281 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
282 }
283 }