[TASK] Streamline functional data handling tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / ManyToMany / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany;
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_CategoryIdFirst = 28;
29 const VALUE_CategoryIdSecond = 29;
30 const VALUE_CategoryIdThird = 30;
31 const VALUE_CategoryIdFourth = 31;
32
33 const TABLE_Page = 'pages';
34 const TABLE_Content = 'tt_content';
35 const TABLE_Category = 'sys_category';
36 const TABLE_ContentCategory_ManyToMany = 'sys_category_record_mm';
37
38 const FIELD_Categories = 'categories';
39
40 /**
41 * @var string
42 */
43 protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/ManyToMany/DataSet/';
44
45 protected function setUp()
46 {
47 parent::setUp();
48 $this->importScenarioDataSet('LiveDefaultPages');
49 $this->importScenarioDataSet('LiveDefaultElements');
50
51 $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
52 $this->backendUser->workspace = 0;
53 }
54
55 /**
56 * MM Relations
57 */
58
59 /**
60 * @see DataSet/addCategoryRelation.csv
61 */
62 public function addCategoryRelation()
63 {
64 $this->actionService->modifyReferences(
65 self::TABLE_Content,
66 self::VALUE_ContentIdFirst,
67 'categories',
68 [self::VALUE_CategoryIdFirst, self::VALUE_CategoryIdSecond, 31]
69 );
70 }
71
72 /**
73 * @see DataSet/deleteCategoryRelation.csv
74 */
75 public function deleteCategoryRelation()
76 {
77 $this->actionService->modifyReferences(
78 self::TABLE_Content,
79 self::VALUE_ContentIdFirst,
80 'categories',
81 [self::VALUE_CategoryIdFirst]
82 );
83 }
84
85 /**
86 * @see DataSet/changeCategoryRelationSorting.csv
87 */
88 public function changeCategoryRelationSorting()
89 {
90 $this->actionService->modifyReferences(
91 self::TABLE_Content,
92 self::VALUE_ContentIdFirst,
93 'categories',
94 [self::VALUE_CategoryIdSecond, self::VALUE_CategoryIdFirst]
95 );
96 }
97
98 /**
99 * @see DataSet/modifyCategoryRecordOfCategoryRelation.csv
100 */
101 public function modifyCategoryOfRelation()
102 {
103 $this->actionService->modifyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, ['title' => 'Testing #1']);
104 }
105
106 /**
107 * @see DataSet/modifyContentRecordOfCategoryRelation.csv
108 */
109 public function modifyContentOfRelation()
110 {
111 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
112 }
113
114 /**
115 * @see DataSet/modifyBothRecordsOfCategoryRelation.csv
116 */
117 public function modifyBothsOfRelation()
118 {
119 $this->actionService->modifyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, ['title' => 'Testing #1']);
120 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
121 }
122
123 /**
124 * @see DataSet/deleteContentRecordOfCategoryRelation.csv
125 */
126 public function deleteContentOfRelation()
127 {
128 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
129 }
130
131 /**
132 * @see DataSet/deleteCategoryRecordOfCategoryRelation.csv
133 */
134 public function deleteCategoryOfRelation()
135 {
136 $this->actionService->deleteRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst);
137 }
138
139 /**
140 * @see DataSet/copyContentRecordOfCategoryRelation.csv
141 */
142 public function copyContentOfRelation()
143 {
144 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
145 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
146 }
147
148 /**
149 * @see DataSet/copyCategoryRecordOfCategoryRelation.csv
150 */
151 public function copyCategoryOfRelation()
152 {
153 $newTableIds = $this->actionService->copyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, 0);
154 $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][self::VALUE_CategoryIdFirst];
155 }
156
157 /**
158 * @see DataSet/copyContentToLanguageOfRelation.csv
159 */
160 public function copyContentToLanguageOfRelation()
161 {
162 $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
163 }
164
165 /**
166 * @see DataSet/copyCategoryToLanguageOfRelation.csv
167 */
168 public function copyCategoryToLanguageOfRelation()
169 {
170 $this->actionService->copyRecordToLanguage(self::TABLE_Category, self::VALUE_CategoryIdFirst, self::VALUE_LanguageId);
171 }
172
173 /**
174 * @see DataSet/localizeContentRecordOfCategoryRelation.csv
175 */
176 public function localizeContentOfRelation()
177 {
178 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
179 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
180 }
181
182 public function localizeContentOfRelationWithLanguageSynchronization()
183 {
184 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_Categories]['config']['behaviour']['allowLanguageSynchronization'] = true;
185 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
186 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
187 }
188
189 public function localizeContentOfRelationAndAddCategoryWithLanguageSynchronization()
190 {
191 self::localizeContentOfRelationWithLanguageSynchronization();
192 $this->actionService->modifyReferences(
193 self::TABLE_Content,
194 self::VALUE_ContentIdLast,
195 self::FIELD_Categories,
196 [self::VALUE_CategoryIdSecond, self::VALUE_CategoryIdThird, self::VALUE_CategoryIdFourth]
197 );
198 }
199
200 public function localizeContentChainOfRelationAndAddCategoryWithLanguageSynchronization()
201 {
202 self::localizeContentOfRelationWithLanguageSynchronization();
203 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['localizedContentId'], self::VALUE_LanguageIdSecond);
204 $this->recordIds['localizedContentIdSecond'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['localizedContentId']];
205 $this->actionService->modifyRecord(
206 self::TABLE_Content,
207 $this->recordIds['localizedContentIdSecond'],
208 ['l10n_state' => [self::FIELD_Categories => 'source']]
209 );
210 $this->actionService->modifyReferences(
211 self::TABLE_Content,
212 self::VALUE_ContentIdLast,
213 self::FIELD_Categories,
214 [self::VALUE_CategoryIdSecond, self::VALUE_CategoryIdThird, self::VALUE_CategoryIdFourth]
215 );
216 }
217
218 /**
219 * @see DataSet/localizeCategoryRecordOfCategoryRelation.csv
220 */
221 public function localizeCategoryOfRelation()
222 {
223 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, self::VALUE_LanguageId);
224 $this->recordIds['localizedCategoryId'] = $localizedTableIds[self::TABLE_Category][self::VALUE_CategoryIdFirst];
225 }
226
227 /**
228 * @see DataSet/moveContentRecordOfCategoryRelationToDifferentPage.csv
229 */
230 public function moveContentOfRelationToDifferentPage()
231 {
232 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
233 }
234
235 /**
236 * @see DataSet/copyPage.csv
237 */
238 public function copyPage()
239 {
240 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
241 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
242 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
243 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
244 }
245 }