033f05835bfafcf68b7d310dcf15427f9b1dfc30
[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 * @test
59 * @see DataSet/addElementRelation.csv
60 */
61 public function addElementRelation()
62 {
63 $this->actionService->modifyReferences(
64 self::TABLE_Content,
65 self::VALUE_ContentIdFirst,
66 self::FIELD_ContentElement,
67 [self::VALUE_ElementIdFirst, self::VALUE_ElementIdSecond, self::VALUE_ElementIdThird]
68 );
69 }
70
71 /**
72 * @test
73 * @see DataSet/deleteElementRelation.csv
74 */
75 public function deleteElementRelation()
76 {
77 $this->actionService->modifyReferences(
78 self::TABLE_Content,
79 self::VALUE_ContentIdFirst,
80 self::FIELD_ContentElement,
81 [self::VALUE_ElementIdFirst]
82 );
83 }
84
85 /**
86 * @test
87 * @see DataSet/changeElementSorting.csv
88 */
89 public function changeElementSorting()
90 {
91 $this->actionService->moveRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, -self::VALUE_ElementIdSecond);
92 }
93
94 /**
95 * @test
96 * @see DataSet/changeElementRelationSorting.csv
97 */
98 public function changeElementRelationSorting()
99 {
100 $this->actionService->modifyReferences(
101 self::TABLE_Content,
102 self::VALUE_ContentIdFirst,
103 self::FIELD_ContentElement,
104 [self::VALUE_ElementIdSecond, self::VALUE_ElementIdFirst]
105 );
106 }
107
108 /**
109 * @test
110 * @see DataSet/createContentNAddRelation.csv
111 */
112 public function createContentAndAddElementRelation()
113 {
114 $newTableIds = $this->actionService->createNewRecord(
115 self::TABLE_Content,
116 self::VALUE_PageId,
117 ['header' => 'Testing #1', self::FIELD_ContentElement => self::VALUE_ElementIdFirst]
118 );
119 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
120 }
121
122 /**
123 * @test
124 * @see DataSet/createContentNCreateRelation.csv
125 */
126 public function createContentAndCreateElementRelation()
127 {
128 $newElementIds = $this->actionService->createNewRecord(self::TABLE_Element, self::VALUE_PageId, ['title' => 'Testing #1']);
129 $this->recordIds['newElementId'] = $newElementIds[self::TABLE_Element][0];
130 // It's not possible to use "NEW..." values for the TCA type 'select' in a workspace, in live it would have been fine
131 $newContentIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1', self::FIELD_ContentElement => $this->recordIds['newElementId']]);
132 $this->recordIds['newContentId'] = $newContentIds[self::TABLE_Content][0];
133 }
134
135 /**
136 * @test
137 * @see DataSet/modifyElementOfRelation.csv
138 */
139 public function modifyElementOfRelation()
140 {
141 $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, ['title' => 'Testing #1']);
142 }
143
144 /**
145 * @test
146 * @see DataSet/modifyContentOfRelation.csv
147 */
148 public function modifyContentOfRelation()
149 {
150 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
151 }
152
153 /**
154 * @test
155 * @see DataSet/modifyBothSidesOfRelation.csv
156 */
157 public function modifyBothSidesOfRelation()
158 {
159 $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, ['title' => 'Testing #1']);
160 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
161 }
162
163 /**
164 * @test
165 * @see DataSet/deleteContentOfRelation.csv
166 */
167 public function deleteContentOfRelation()
168 {
169 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
170 }
171
172 /**
173 * @test
174 * @see DataSet/deleteElementOfRelation.csv
175 */
176 public function deleteElementOfRelation()
177 {
178 $this->actionService->deleteRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
179 }
180
181 /**
182 * @test
183 * @see DataSet/copyContentOfRelation.csv
184 */
185 public function copyContentOfRelation()
186 {
187 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
188 $this->recordIds['copiedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
189 }
190
191 /**
192 * @test
193 * @see DataSet/copyElementOfRelation.csv
194 */
195 public function copyElementOfRelation()
196 {
197 $newTableIds = $this->actionService->copyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_PageId);
198 $this->recordIds['copiedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
199 }
200
201 /**
202 * @test
203 * @see DataSet/copyContentToLanguageOfRelation.csv
204 */
205 public function copyContentToLanguageOfRelation()
206 {
207 $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
208 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
209 }
210
211 /**
212 * @test
213 * @see DataSet/copyElementToLanguageOfRelation.csv
214 */
215 public function copyElementToLanguageOfRelation()
216 {
217 $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
218 $this->recordIds['localizedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
219 }
220
221 /**
222 * @test
223 * @see DataSet/localizeContentOfRelation.csv
224 */
225 public function localizeContentOfRelation()
226 {
227 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
228 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
229 }
230
231 /**
232 * @test
233 * @see DataSet/localizeElementOfRelation.csv
234 */
235 public function localizeElementOfRelation()
236 {
237 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
238 $this->recordIds['localizedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
239 }
240
241 /**
242 * @test
243 * @see DataSet/moveContentOfRelationToDifferentPage.csv
244 */
245 public function moveContentOfRelationToDifferentPage()
246 {
247 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
248 }
249 }