[!!!][TASK] Remove wizard icons
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Form / FormDataProvider / TcaFlexPrepareTest.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
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 use TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexPrepare;
18 use TYPO3\CMS\Core\Tests\UnitTestCase;
19
20 /**
21 * Test case
22 */
23 class TcaFlexPrepareTest extends UnitTestCase
24 {
25 /**
26 * @var TcaFlexPrepare
27 */
28 protected $subject;
29
30 protected function setUp()
31 {
32 $this->subject = new TcaFlexPrepare();
33 }
34
35 /**
36 * @test
37 */
38 public function addDataThrowsExceptionIfBothSheetsAndRootDefined()
39 {
40 $input = [
41 'systemLanguageRows' => [],
42 'databaseRow' => [
43 'aField' => [
44 'data' => [],
45 'meta' => [],
46 ],
47 ],
48 'processedTca' => [
49 'columns' => [
50 'aField' => [
51 'config' => [
52 'type' => 'flex',
53 'ds' => [
54 'ROOT' => [],
55 'sheets' => [],
56 ],
57 ],
58 ],
59 ],
60 ],
61 ];
62
63 $this->expectException(\UnexpectedValueException::class);
64 $this->expectExceptionCode(1440676540);
65
66 $this->subject->addData($input);
67 }
68
69 /**
70 * @test
71 */
72 public function addDataRemovesTceFormsFromArrayKeys()
73 {
74 $input = [
75 'processedTca' => [
76 'columns' => [
77 'aField' => [
78 'config' => [
79 'type' => 'flex',
80 'ds' => [
81 'sheets' => [
82 'sDEF' => [
83 'ROOT' => [
84 'TCEforms' => [
85 'sheetDescription' => 'aDescription',
86 'displayCond' => 'aDisplayCond',
87 ],
88 'type' => 'array',
89 'el' => [
90 'aFlexField' => [
91 'TCEforms' => [
92 'label' => 'aFlexFieldLabel',
93 'config' => [
94 'type' => 'input',
95 ],
96 ],
97 ],
98 ],
99 ],
100 ],
101 'sOther' => [
102 'ROOT' => [
103 'TCEforms' => [
104 'sheetTitle' => 'anotherTitle',
105 ],
106 'type' => 'array',
107 'el' => [
108 'bFlexField' => [
109 'TCEforms' => [
110 'label' => 'bFlexFieldLabel',
111 'config' => [
112 'type' => 'input',
113 ],
114 ],
115 ],
116 ],
117 ],
118 ],
119 ],
120 ],
121 ],
122 ],
123 ],
124 ],
125 ];
126
127 $expected = $input;
128 $expected['processedTca']['columns']['aField']['config']['ds'] = [
129 'sheets' => [
130 'sDEF' => [
131 'ROOT' => [
132 'type' => 'array',
133 'el' => [
134 'aFlexField' => [
135 'label' => 'aFlexFieldLabel',
136 'config' => [
137 'type' => 'input',
138 ],
139 ],
140 ],
141 'sheetDescription' => 'aDescription',
142 'displayCond' => 'aDisplayCond',
143 ],
144 ],
145 'sOther' => [
146 'ROOT' => [
147 'type' => 'array',
148 'el' => [
149 'bFlexField' => [
150 'label' => 'bFlexFieldLabel',
151 'config' => [
152 'type' => 'input',
153 ],
154 ],
155 ],
156 'sheetTitle' => 'anotherTitle',
157 ],
158 ],
159 ],
160 ];
161
162 $this->assertEquals($expected, $this->subject->addData($input));
163 }
164
165 /**
166 * @test
167 */
168 public function addDataMigratesFlexformTca()
169 {
170 $input = [
171 'processedTca' => [
172 'columns' => [
173 'aField' => [
174 'config' => [
175 'type' => 'flex',
176 'ds' => [
177 'sheets' => [
178 'sDEF' => [
179 'ROOT' => [
180 'type' => 'array',
181 'el' => [
182 'aFlexField' => [
183 'TCEforms' => [
184 'label' => 'aFlexFieldLabel',
185 'config' => [
186 'type' => 'text',
187 'default' => 'defaultValue',
188 'wizards' => [
189 't3editor' => [
190 'type' => 'userFunc',
191 'userFunc' => 'TYPO3\\CMS\\T3editor\\FormWizard->main',
192 'title' => 't3editor',
193 'icon' => 'content-table',
194 'module' => [
195 'name' => 'wizard_table',
196 ],
197 'params' => [
198 'format' => 'html',
199 ],
200 ],
201 ],
202 ],
203 ],
204 ],
205 ],
206 ],
207 ],
208 ],
209 ],
210 ],
211 ],
212 ],
213 ],
214 ];
215
216 $expected = $input;
217 $expected['processedTca']['columns']['aField']['config']['ds'] = [
218 'sheets' => [
219 'sDEF' => [
220 'ROOT' => [
221 'type' => 'array',
222 'el' => [
223 'aFlexField' => [
224 'label' => 'aFlexFieldLabel',
225 'config' => [
226 'type' => 'text',
227 'default' => 'defaultValue',
228 'renderType' => 't3editor',
229 'format' => 'html',
230 ],
231 ],
232 ],
233 ],
234 ],
235 ],
236 ];
237
238 $this->assertEquals($expected, $this->subject->addData($input));
239 }
240
241 /**
242 * @test
243 */
244 public function addDataMigratesFlexformTcaInContainer()
245 {
246 $input = [
247 'processedTca' => [
248 'columns' => [
249 'aField' => [
250 'config' => [
251 'type' => 'flex',
252 'ds_pointerField' => 'pointerField',
253 'ds' => [
254 'sheets' => [
255 'sDEF' => [
256 'ROOT' => [
257 'type' => 'array',
258 'el' => [
259 'section_1' => [
260 'title' => 'section_1',
261 'type' => 'array',
262 'section' => '1',
263 'el' => [
264 'aFlexContainer' => [
265 'type' => 'array',
266 'title' => 'aFlexContainerLabel',
267 'el' => [
268 'aFlexField' => [
269 'TCEforms' => [
270 'label' => 'aFlexFieldLabel',
271 'config' => [
272 'type' => 'text',
273 'default' => 'defaultValue',
274 'wizards' => [
275 't3editor' => [
276 'type' => 'userFunc',
277 'userFunc' => 'TYPO3\CMS\T3editor\FormWizard->main',
278 'title' => 't3editor',
279 'icon' => 'content-table',
280 'module' => [
281 'name' => 'wizard_table',
282 ],
283 'params' => [
284 'format' => 'html',
285 ],
286 ],
287 ],
288 ],
289 ],
290 ],
291 ],
292 ],
293 ],
294 ],
295 ],
296 ],
297 ],
298 ],
299 ],
300 ],
301 ],
302 ],
303 ],
304 ];
305
306 $expected = $input;
307 $expected['processedTca']['columns']['aField']['config']['ds'] = [
308 'sheets' => [
309 'sDEF' => [
310 'ROOT' => [
311 'type' => 'array',
312 'el' => [
313 'section_1' => [
314 'title' => 'section_1',
315 'type' => 'array',
316 'section' => '1',
317 'el' => [
318 'aFlexContainer' => [
319 'type' => 'array',
320 'title' => 'aFlexContainerLabel',
321 'el' => [
322 'aFlexField' => [
323 'label' => 'aFlexFieldLabel',
324 'config' => [
325 'type' => 'text',
326 'default' => 'defaultValue',
327 'renderType' => 't3editor',
328 'format' => 'html',
329 ],
330 ],
331 ],
332 ],
333 ],
334 ],
335 ],
336 ],
337 ],
338 ],
339 ];
340
341 $this->assertEquals($expected, $this->subject->addData($input));
342 }
343 }