[TASK] Streamline functional data handling tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / Select / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Select;
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_ElementIdFirst = 1;
28 const VALUE_ElementIdSecond = 2;
29 const VALUE_ElementIdThird = 3;
30
31 const TABLE_Content = 'tt_content';
32 const TABLE_Element = 'tx_testdatahandler_element';
33
34 const FIELD_ContentElement = 'tx_testdatahandler_select';
35
36 /**
37 * @var string
38 */
39 protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Select/DataSet/';
40
41 protected function setUp()
42 {
43 $this->testExtensionsToLoad[] = 'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_datahandler';
44
45 parent::setUp();
46 $this->importScenarioDataSet('LiveDefaultPages');
47 $this->importScenarioDataSet('LiveDefaultElements');
48 $this->importScenarioDataSet('ReferenceIndex');
49
50 $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
51 }
52
53 /**
54 * Relations
55 */
56
57 /**
58 * @see DataSet/addElementRelation.csv
59 */
60 public function addElementRelation()
61 {
62 $this->actionService->modifyReferences(
63 self::TABLE_Content,
64 self::VALUE_ContentIdFirst,
65 self::FIELD_ContentElement,
66 [self::VALUE_ElementIdFirst, self::VALUE_ElementIdSecond, self::VALUE_ElementIdThird]
67 );
68 }
69
70 /**
71 * @see DataSet/deleteElementRelation.csv
72 */
73 public function deleteElementRelation()
74 {
75 $this->actionService->modifyReferences(
76 self::TABLE_Content,
77 self::VALUE_ContentIdFirst,
78 self::FIELD_ContentElement,
79 [self::VALUE_ElementIdFirst]
80 );
81 }
82
83 /**
84 * @see DataSet/changeElementSorting.csv
85 */
86 public function changeElementSorting()
87 {
88 $this->actionService->moveRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, -self::VALUE_ElementIdSecond);
89 }
90
91 /**
92 * @see DataSet/changeElementRelationSorting.csv
93 */
94 public function changeElementRelationSorting()
95 {
96 $this->actionService->modifyReferences(
97 self::TABLE_Content,
98 self::VALUE_ContentIdFirst,
99 self::FIELD_ContentElement,
100 [self::VALUE_ElementIdSecond, self::VALUE_ElementIdFirst]
101 );
102 }
103
104 /**
105 * @see DataSet/createContentNAddRelation.csv
106 */
107 public function createContentAndAddElementRelation()
108 {
109 $newTableIds = $this->actionService->createNewRecord(
110 self::TABLE_Content,
111 self::VALUE_PageId,
112 ['header' => 'Testing #1', self::FIELD_ContentElement => self::VALUE_ElementIdFirst]
113 );
114 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
115 }
116
117 /**
118 * @see DataSet/createContentNCreateRelation.csv
119 */
120 public function createContentAndCreateElementRelation()
121 {
122 $newElementIds = $this->actionService->createNewRecord(self::TABLE_Element, self::VALUE_PageId, ['title' => 'Testing #1']);
123 $this->recordIds['newElementId'] = $newElementIds[self::TABLE_Element][0];
124 // It's not possible to use "NEW..." values for the TCA type 'select' in a workspace, in live it would have been fine
125 $newContentIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1', self::FIELD_ContentElement => $this->recordIds['newElementId']]);
126 $this->recordIds['newContentId'] = $newContentIds[self::TABLE_Content][0];
127 }
128
129 /**
130 * @see DataSet/modifyElementOfRelation.csv
131 */
132 public function modifyElementOfRelation()
133 {
134 $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, ['title' => 'Testing #1']);
135 }
136
137 /**
138 * @see DataSet/modifyContentOfRelation.csv
139 */
140 public function modifyContentOfRelation()
141 {
142 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
143 }
144
145 /**
146 * @see DataSet/modifyBothSidesOfRelation.csv
147 */
148 public function modifyBothSidesOfRelation()
149 {
150 $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, ['title' => 'Testing #1']);
151 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
152 }
153
154 /**
155 * @see DataSet/deleteContentOfRelation.csv
156 */
157 public function deleteContentOfRelation()
158 {
159 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
160 }
161
162 /**
163 * @see DataSet/deleteElementOfRelation.csv
164 */
165 public function deleteElementOfRelation()
166 {
167 $this->actionService->deleteRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
168 }
169
170 /**
171 * @see DataSet/copyContentOfRelation.csv
172 */
173 public function copyContentOfRelation()
174 {
175 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
176 $this->recordIds['copiedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
177 }
178
179 /**
180 * @see DataSet/copyElementOfRelation.csv
181 */
182 public function copyElementOfRelation()
183 {
184 $newTableIds = $this->actionService->copyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_PageId);
185 $this->recordIds['copiedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
186 }
187
188 /**
189 * @see DataSet/copyContentToLanguageOfRelation.csv
190 */
191 public function copyContentToLanguageOfRelation()
192 {
193 $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
194 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
195 }
196
197 /**
198 * @see DataSet/copyElementToLanguageOfRelation.csv
199 */
200 public function copyElementToLanguageOfRelation()
201 {
202 $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
203 $this->recordIds['localizedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
204 }
205
206 /**
207 * @see DataSet/localizeContentOfRelation.csv
208 */
209 public function localizeContentOfRelation()
210 {
211 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
212 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
213 }
214
215 /**
216 * @see DataSet/localizeElementOfRelation.csv
217 */
218 public function localizeElementOfRelation()
219 {
220 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
221 $this->recordIds['localizedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
222 }
223
224 /**
225 * @see DataSet/moveContentOfRelationToDifferentPage.csv
226 */
227 public function moveContentOfRelationToDifferentPage()
228 {
229 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
230 }
231 }