e6c243f13a17f2d6508bfa48a72dc7948f3b4e0b
[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 * @test
61 * @see DataSet/addCategoryRelation.csv
62 */
63 public function addCategoryRelation()
64 {
65 $this->actionService->modifyReferences(
66 self::TABLE_Content,
67 self::VALUE_ContentIdFirst,
68 'categories',
69 [self::VALUE_CategoryIdFirst, self::VALUE_CategoryIdSecond, 31]
70 );
71 }
72
73 /**
74 * @test
75 * @see DataSet/deleteCategoryRelation.csv
76 */
77 public function deleteCategoryRelation()
78 {
79 $this->actionService->modifyReferences(
80 self::TABLE_Content,
81 self::VALUE_ContentIdFirst,
82 'categories',
83 [self::VALUE_CategoryIdFirst]
84 );
85 }
86
87 /**
88 * @test
89 * @see DataSet/changeCategoryRelationSorting.csv
90 */
91 public function changeCategoryRelationSorting()
92 {
93 $this->actionService->modifyReferences(
94 self::TABLE_Content,
95 self::VALUE_ContentIdFirst,
96 'categories',
97 [self::VALUE_CategoryIdSecond, self::VALUE_CategoryIdFirst]
98 );
99 }
100
101 /**
102 * @test
103 * @see DataSet/modifyCategoryRecordOfCategoryRelation.csv
104 */
105 public function modifyCategoryOfRelation()
106 {
107 $this->actionService->modifyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, ['title' => 'Testing #1']);
108 }
109
110 /**
111 * @test
112 * @see DataSet/modifyContentRecordOfCategoryRelation.csv
113 */
114 public function modifyContentOfRelation()
115 {
116 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
117 }
118
119 /**
120 * @test
121 * @see DataSet/modifyBothRecordsOfCategoryRelation.csv
122 */
123 public function modifyBothsOfRelation()
124 {
125 $this->actionService->modifyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, ['title' => 'Testing #1']);
126 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
127 }
128
129 /**
130 * @test
131 * @see DataSet/deleteContentRecordOfCategoryRelation.csv
132 */
133 public function deleteContentOfRelation()
134 {
135 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
136 }
137
138 /**
139 * @test
140 * @see DataSet/deleteCategoryRecordOfCategoryRelation.csv
141 */
142 public function deleteCategoryOfRelation()
143 {
144 $this->actionService->deleteRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst);
145 }
146
147 /**
148 * @test
149 * @see DataSet/copyContentRecordOfCategoryRelation.csv
150 */
151 public function copyContentOfRelation()
152 {
153 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
154 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
155 }
156
157 /**
158 * @test
159 * @see DataSet/copyCategoryRecordOfCategoryRelation.csv
160 */
161 public function copyCategoryOfRelation()
162 {
163 $newTableIds = $this->actionService->copyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, 0);
164 $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][self::VALUE_CategoryIdFirst];
165 }
166
167 /**
168 * @test
169 * @see DataSet/copyContentToLanguageOfRelation.csv
170 */
171 public function copyContentToLanguageOfRelation()
172 {
173 $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
174 }
175
176 /**
177 * @test
178 * @see DataSet/copyCategoryToLanguageOfRelation.csv
179 */
180 public function copyCategoryToLanguageOfRelation()
181 {
182 $this->actionService->copyRecordToLanguage(self::TABLE_Category, self::VALUE_CategoryIdFirst, self::VALUE_LanguageId);
183 }
184
185 /**
186 * @test
187 * @see DataSet/localizeContentRecordOfCategoryRelation.csv
188 */
189 public function localizeContentOfRelation()
190 {
191 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
192 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
193 }
194
195 public function localizeContentOfRelationWithLanguageSynchronization()
196 {
197 $GLOBALS['TCA'][self::TABLE_Content]['columns'][self::FIELD_Categories]['config']['behaviour']['allowLanguageSynchronization'] = true;
198 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
199 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
200 }
201
202 public function localizeContentOfRelationAndAddCategoryWithLanguageSynchronization()
203 {
204 self::localizeContentOfRelationWithLanguageSynchronization();
205 $this->actionService->modifyReferences(
206 self::TABLE_Content,
207 self::VALUE_ContentIdLast,
208 self::FIELD_Categories,
209 [self::VALUE_CategoryIdSecond, self::VALUE_CategoryIdThird, self::VALUE_CategoryIdFourth]
210 );
211 }
212
213 public function localizeContentChainOfRelationAndAddCategoryWithLanguageSynchronization()
214 {
215 self::localizeContentOfRelationWithLanguageSynchronization();
216 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['localizedContentId'], self::VALUE_LanguageIdSecond);
217 $this->recordIds['localizedContentIdSecond'] = $localizedTableIds[self::TABLE_Content][$this->recordIds['localizedContentId']];
218 $this->actionService->modifyRecord(
219 self::TABLE_Content,
220 $this->recordIds['localizedContentIdSecond'],
221 ['l10n_state' => [self::FIELD_Categories => 'source']]
222 );
223 $this->actionService->modifyReferences(
224 self::TABLE_Content,
225 self::VALUE_ContentIdLast,
226 self::FIELD_Categories,
227 [self::VALUE_CategoryIdSecond, self::VALUE_CategoryIdThird, self::VALUE_CategoryIdFourth]
228 );
229 }
230
231 /**
232 * @test
233 * @see DataSet/localizeCategoryRecordOfCategoryRelation.csv
234 */
235 public function localizeCategoryOfRelation()
236 {
237 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, self::VALUE_LanguageId);
238 $this->recordIds['localizedCategoryId'] = $localizedTableIds[self::TABLE_Category][self::VALUE_CategoryIdFirst];
239 }
240
241 /**
242 * @test
243 * @see DataSet/moveContentRecordOfCategoryRelationToDifferentPage.csv
244 */
245 public function moveContentOfRelationToDifferentPage()
246 {
247 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
248 }
249
250 /**
251 * @test
252 * @see DataSet/copyPage.csv
253 */
254 public function copyPage()
255 {
256 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
257 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
258 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
259 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
260 }
261 }