[TASK] Make core/Tests/Unit/Migrations/ notice free
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Migrations / TcaMigrationTest.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Core\Tests\Unit\Migrations;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 use TYPO3\CMS\Core\Migrations\TcaMigration;
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20
21 /**
22 * Test case
23 */
24 class TcaMigrationTest extends UnitTestCase
25 {
26 /**
27 * @test
28 */
29 public function missingTypeThrowsException(): void
30 {
31 $input = [
32 'aTable' => [
33 'columns' => [
34 'field_a' => [
35 'label' => 'aLabel',
36 'config' => [
37 'type' => 'text',
38 ],
39 ],
40 'field_b' => [
41 'label' => 'bLabel',
42 'config' => [
43 'rows' => 42,
44 'wizards' => []
45 ],
46 ],
47 ],
48 ],
49 ];
50 $this->expectException(\RuntimeException::class);
51 $this->expectExceptionCode(1482394401);
52 $subject = new TcaMigration();
53 $subject->migrate($input);
54 }
55
56 /**
57 * @test
58 */
59 public function migrateReturnsGivenArrayUnchangedIfNoMigrationNeeded(): void
60 {
61 $input = $expected = [
62 'aTable' => [
63 'ctrl' => [
64 'aKey' => 'aValue',
65 ],
66 'columns' => [
67 'aField' => [
68 'label' => 'foo',
69 'config' => [
70 'type' => 'aType',
71 'lolli' => 'did this',
72 ]
73 ],
74 ],
75 'types' => [
76 0 => [
77 'showitem' => 'this,should;stay,this,too',
78 ],
79 ],
80 ],
81 ];
82 $subject = new TcaMigration();
83 $this->assertEquals($expected, $subject->migrate($input));
84 }
85
86 /**
87 * @test
88 */
89 public function migrateAddsMissingColumnsConfig(): void
90 {
91 $input = [
92 'aTable' => [
93 'columns' => [
94 'aField' => [
95 'exclude' => true,
96 ],
97 'bField' => [
98 ],
99 'cField' => [
100 'config' => 'i am a string but should be an array',
101 ],
102 'dField' => [
103 // This kept as is, 'config' is not added. This is relevant
104 // for "flex" data structure arrays with section containers
105 // that have 'type'=>'array' on this level and an 'el' sub array
106 // with details.
107 'type' => 'array',
108 ],
109 ]
110 ],
111 ];
112 $expected = [
113 'aTable' => [
114 'columns' => [
115 'aField' => [
116 'exclude' => true,
117 'config' => [
118 'type' => 'none',
119 ],
120 ],
121 'bField' => [
122 'config' => [
123 'type' => 'none',
124 ],
125 ],
126 'cField' => [
127 'config' => [
128 'type' => 'none',
129 ],
130 ],
131 'dField' => [
132 'type' => 'array',
133 ],
134 ],
135 ],
136 ];
137 $subject = new TcaMigration();
138 $this->assertEquals($expected, $subject->migrate($input));
139 }
140
141 /**
142 * @test
143 */
144 public function migrateChangesT3editorWizardToT3editorRenderTypeIfNotEnabledByTypeConfig(): void
145 {
146 $input = [
147 'aTable' => [
148 'columns' => [
149 'bodytext' => [
150 'exclude' => true,
151 'label' => 'aLabel',
152 'config' => [
153 'type' => 'text',
154 'rows' => 42,
155 'wizards' => [
156 't3editor' => [
157 'type' => 'userFunc',
158 'userFunc' => 'TYPO3\CMS\T3editor\FormWizard->main',
159 'title' => 't3editor',
160 'icon' => 'content-table',
161 'module' => [
162 'name' => 'wizard_table'
163 ],
164 'params' => [
165 'format' => 'html',
166 'style' => 'width:98%; height: 60%;'
167 ],
168 ],
169 ],
170 ],
171 ],
172 ],
173 ],
174 ];
175 $expected = [
176 'aTable' => [
177 'columns' => [
178 'bodytext' => [
179 'exclude' => true,
180 'label' => 'aLabel',
181 'config' => [
182 'type' => 'text',
183 'renderType' => 't3editor',
184 'format' => 'html',
185 'rows' => 42,
186 ],
187 ],
188 ],
189 ],
190 ];
191 $subject = new TcaMigration();
192 $this->assertEquals($expected, $subject->migrate($input));
193 }
194
195 /**
196 * @test
197 */
198 public function migrateDropsStylePointerFromShowItem(): void
199 {
200 $input = [
201 'aTable' => [
202 'types' => [
203 0 => [
204 'showitem' => 'aField,anotherField;with;;;style-pointer,thirdField',
205 ],
206 1 => [
207 'showitem' => 'aField,;;;;only-a-style-pointer,anotherField',
208 ],
209 ],
210 ],
211 ];
212 $expected = [
213 'aTable' => [
214 'types' => [
215 0 => [
216 'showitem' => 'aField,anotherField;with,thirdField',
217 ],
218 1 => [
219 'showitem' => 'aField,anotherField',
220 ],
221 ],
222 ],
223 ];
224 $subject = new TcaMigration();
225 $this->assertEquals($expected, $subject->migrate($input));
226 }
227
228 /**
229 * @test
230 */
231 public function migrateMovesSpecialConfigurationToColumnsOverridesDefaultExtras(): void
232 {
233 $input = [
234 'aTable' => [
235 'types' => [
236 0 => [
237 'showitem' => 'aField,anotherField;with;;nowrap,thirdField',
238 ],
239 ],
240 ],
241 ];
242 $expected = [
243 'aTable' => [
244 'types' => [
245 0 => [
246 'showitem' => 'aField,anotherField;with,thirdField',
247 'columnsOverrides' => [
248 'anotherField' => [
249 'config' => [
250 'wrap' => 'off',
251 ]
252 ],
253 ],
254 ],
255 ],
256 ],
257 ];
258 $subject = new TcaMigration();
259 $this->assertEquals($expected, $subject->migrate($input));
260 }
261
262 /**
263 * @test
264 */
265 public function migrateMovesSpecialConfigurationToColumnsOverridesDefaultExtrasAndMergesExistingDefaultExtras(): void
266 {
267 $input = [
268 'aTable' => [
269 'columns' => [
270 'anotherField' => [
271 'defaultExtras' => 'nowrap',
272 'config' => [
273 'type' => 'text',
274 ],
275 ],
276 ],
277 'types' => [
278 0 => [
279 'showitem' => 'aField,anotherField;with;;enable-tab,thirdField',
280 ],
281 ],
282 ],
283 ];
284 $expected = [
285 'aTable' => [
286 'columns' => [
287 'anotherField' => [
288 'config' => [
289 'wrap' => 'off',
290 'type' => 'text',
291 ],
292 ],
293 ],
294 'types' => [
295 0 => [
296 'showitem' => 'aField,anotherField;with,thirdField',
297 'columnsOverrides' => [
298 'anotherField' => [
299 'config' => [
300 'wrap' => 'off',
301 'enableTabulator' => true,
302 ],
303 ],
304 ],
305 ],
306 ],
307 ],
308 ];
309 $subject = new TcaMigration();
310 $this->assertEquals($expected, $subject->migrate($input));
311 }
312
313 /**
314 * @test
315 */
316 public function migrateChangesT3editorWizardThatIsEnabledByTypeConfigToRenderTypeInColumnsOverrides(): void
317 {
318 $input = [
319 'aTable' => [
320 'columns' => [
321 'bodytext' => [
322 'exclude' => true,
323 'label' => 'aLabel',
324 'config' => [
325 'type' => 'text',
326 'rows' => 42,
327 'wizards' => [
328 't3editorHtml' => [
329 'type' => 'userFunc',
330 'userFunc' => 'TYPO3\CMS\T3editor\FormWizard->main',
331 'enableByTypeConfig' => 1,
332 'title' => 't3editor',
333 'icon' => 'content-table',
334 'module' => [
335 'name' => 'wizard_table'
336 ],
337 'params' => [
338 'format' => 'html',
339 'style' => 'width:98%; height: 60%;'
340 ],
341 ],
342 't3editorTypoScript' => [
343 'type' => 'userFunc',
344 'userFunc' => 'TYPO3\CMS\T3editor\FormWizard->main',
345 'enableByTypeConfig' => 1,
346 'title' => 't3editor',
347 'icon' => 'content-table',
348 'module' => [
349 'name' => 'wizard_table'
350 ],
351 'params' => [
352 'format' => 'typoscript',
353 'style' => 'width:98%; height: 60%;'
354 ],
355 ],
356 ],
357 ],
358 ],
359 ],
360 'types' => [
361 'firstType' => [
362 'showitem' => 'foo,bodytext;;;wizards[t3editorTypoScript|someOtherWizard],bar',
363 ],
364 'secondType' => [
365 'showitem' => 'foo,bodytext;;;nowrap:wizards[t3editorHtml], bar',
366 ],
367 ],
368 ],
369 ];
370 $expected = [
371 'aTable' => [
372 'columns' => [
373 'bodytext' => [
374 'exclude' => true,
375 'label' => 'aLabel',
376 'config' => [
377 'type' => 'text',
378 'rows' => 42,
379 ],
380 ],
381 ],
382 'types' => [
383 'firstType' => [
384 'showitem' => 'foo,bodytext,bar',
385 'columnsOverrides' => [
386 'bodytext' => [
387 'config' => [
388 'format' => 'typoscript',
389 'renderType' => 't3editor',
390 ],
391 ],
392 ],
393 ],
394 'secondType' => [
395 'showitem' => 'foo,bodytext,bar',
396 'columnsOverrides' => [
397 'bodytext' => [
398 'config' => [
399 'format' => 'html',
400 'renderType' => 't3editor',
401 'wrap' => 'off',
402 ],
403 ],
404 ],
405 ],
406 ],
407 ],
408 ];
409 $subject = new TcaMigration();
410 $this->assertEquals($expected, $subject->migrate($input));
411 }
412
413 /**
414 * @test
415 */
416 public function migrateRemovesAnUnusedT3edtiorDefinitionIfEnabledByTypeConfig(): void
417 {
418 $input = [
419 'aTable' => [
420 'columns' => [
421 'bodytext' => [
422 'exclude' => true,
423 'label' => 'aLabel',
424 'config' => [
425 'type' => 'text',
426 'rows' => 42,
427 'wizards' => [
428 't3editorHtml' => [
429 'type' => 'userFunc',
430 'userFunc' => 'TYPO3\CMS\T3editor\FormWizard->main',
431 'enableByTypeConfig' => 1,
432 'title' => 't3editor',
433 'icon' => 'content-table',
434 'module' => [
435 'name' => 'wizard_table'
436 ],
437 'params' => [
438 'format' => 'html',
439 'style' => 'width:98%; height: 60%;'
440 ],
441 ],
442 ],
443 ],
444 ],
445 ],
446 ],
447 ];
448 $expected = [
449 'aTable' => [
450 'columns' => [
451 'bodytext' => [
452 'exclude' => true,
453 'label' => 'aLabel',
454 'config' => [
455 'type' => 'text',
456 'rows' => 42,
457 ],
458 ],
459 ],
460 ],
461 ];
462 $subject = new TcaMigration();
463 $this->assertEquals($expected, $subject->migrate($input));
464 }
465
466 /**
467 * @test
468 */
469 public function migrateSpecialConfigurationAndRemoveShowItemStylePointerConfigDoesNotAddMessageIfOnlySyntaxChanged(): void
470 {
471 $input = [
472 'aTable' => [
473 'columns' => [
474 'anotherField' => [
475 'config' => [
476 'type' => 'text',
477 ],
478 ],
479 ],
480 'types' => [
481 0 => [
482 'showitem' => 'aField;;;',
483 ],
484 1 => []
485 ],
486 ],
487 ];
488 $subject = new TcaMigration();
489 $subject->migrate($input);
490 $this->assertEmpty($subject->getMessages());
491 }
492
493 /**
494 * @test
495 */
496 public function migrateShowItemMovesAdditionalPaletteToOwnPaletteDefinition(): void
497 {
498 $input = [
499 'aTable' => [
500 'types' => [
501 'firstType' => [
502 'showitem' => 'field1;field1Label,field2;fieldLabel2;palette1,field2;;palette2',
503 ],
504 ],
505 ],
506 ];
507 $expected = [
508 'aTable' => [
509 'types' => [
510 'firstType' => [
511 'showitem' => 'field1;field1Label,field2;fieldLabel2,--palette--;;palette1,field2,--palette--;;palette2',
512 ],
513 ],
514 ],
515 ];
516 $subject = new TcaMigration();
517 $this->assertEquals($expected, $subject->migrate($input));
518 }
519
520 /**
521 * @test
522 */
523 public function migrateIconsForFormFieldWizardToNewLocation(): void
524 {
525 $input = [
526 'aTable' => [
527 'columns' => [
528 'bodytext' => [
529 'config' => [
530 'type' => 'text',
531 'wizards' => [
532 't3editorHtml' => [
533 'icon' => 'wizard_table.gif',
534 ],
535 ],
536 ],
537 ],
538 ],
539 ],
540 ];
541
542 $expected = [
543 'aTable' => [
544 'columns' => [
545 'bodytext' => [
546 'config' => [
547 'type' => 'text',
548 'wizards' => [
549 't3editorHtml' => [
550 'icon' => 'content-table',
551 ],
552 ],
553 ],
554 ],
555 ],
556 ],
557 ];
558
559 $subject = new TcaMigration();
560 $this->assertEquals($expected, $subject->migrate($input));
561 }
562
563 /**
564 * @test
565 */
566 public function migrateExtAndSysextPathToEXTPath(): void
567 {
568 $input = [
569 'aTable' => [
570 'columns' => [
571 'foo' => [
572 'config' => [
573 'type' => 'select',
574 'items' => [
575 ['foo', 0, 'ext/myext/foo/bar.gif'],
576 ['bar', 1, 'sysext/myext/foo/bar.gif'],
577 ],
578 ],
579 ],
580 ],
581 ],
582 ];
583
584 $expected = [
585 'aTable' => [
586 'columns' => [
587 'foo' => [
588 'config' => [
589 'type' => 'select',
590 'renderType' => 'selectSingle',
591 'items' => [
592 ['foo', 0, 'EXT:myext/foo/bar.gif'],
593 ['bar', 1, 'EXT:myext/foo/bar.gif'],
594 ],
595 ],
596 ],
597 ],
598 ],
599 ];
600
601 $subject = new TcaMigration();
602 $this->assertEquals($expected, $subject->migrate($input));
603 }
604
605 /**
606 * @test
607 */
608 public function migratePathWhichStartsWithIToEXTPath(): void
609 {
610 $input = [
611 'aTable' => [
612 'columns' => [
613 'foo' => [
614 'config' => [
615 'type' => 'select',
616 'items' => [
617 ['foo', 0, 'i/tt_content.gif'],
618 ],
619 ],
620 ],
621 ],
622 ],
623 ];
624
625 $expected = [
626 'aTable' => [
627 'columns' => [
628 'foo' => [
629 'config' => [
630 'type' => 'select',
631 'renderType' => 'selectSingle',
632 'items' => [
633 ['foo', 0, 'EXT:backend/Resources/Public/Images/tt_content.gif'],
634 ],
635 ],
636 ],
637 ],
638 ],
639 ];
640
641 $subject = new TcaMigration();
642 $this->assertEquals($expected, $subject->migrate($input));
643 }
644
645 /**
646 * @test
647 */
648 public function migrateRemovesIconsInOptionTags(): void
649 {
650 $input = [
651 'aTable' => [
652 'columns' => [
653 'foo' => [
654 'config' => [
655 'type' => 'select',
656 'iconsInOptionTags' => 1,
657 ],
658 ],
659 ],
660 ],
661 ];
662 $expected = [
663 'aTable' => [
664 'columns' => [
665 'foo' => [
666 'config' => [
667 'type' => 'select',
668 'renderType' => 'selectSingle',
669 ],
670 ],
671 ],
672 ],
673 ];
674
675 $subject = new TcaMigration();
676 $this->assertEquals($expected, $subject->migrate($input));
677 }
678
679 /**
680 * @test
681 */
682 public function migrateRewritesRelativeIconPathToExtensionReference(): void
683 {
684 $input = [
685 'aTable' => [
686 'ctrl' => [
687 'iconfile' => '../typo3conf/ext/myExt/iconfile.gif',
688 ],
689 ],
690 ];
691 $expected = [
692 'aTable' => [
693 'ctrl' => [
694 'iconfile' => 'EXT:myExt/iconfile.gif',
695 ],
696 ],
697 ];
698 $subject = new TcaMigration();
699 $this->assertEquals($expected, $subject->migrate($input));
700 }
701
702 /**
703 * @test
704 */
705 public function migrateRewritesIconFilenameOnlyToDefaultT3skinExtensionReference(): void
706 {
707 $input = [
708 'aTable' => [
709 'ctrl' => [
710 'iconfile' => 'iconfile.gif',
711 ],
712 ],
713 ];
714 $expected = [
715 'aTable' => [
716 'ctrl' => [
717 'iconfile' => 'EXT:backend/Resources/Public/Images/iconfile.gif',
718 ],
719 ],
720 ];
721 $subject = new TcaMigration();
722 $this->assertEquals($expected, $subject->migrate($input));
723 }
724
725 /**
726 * @test
727 */
728 public function migrateKeepsGivenExtensionReference(): void
729 {
730 $input = [
731 'aTable' => [
732 'ctrl' => [
733 'iconfile' => 'EXT:myExt/iconfile.gif',
734 ],
735 ],
736 ];
737 $expected = [
738 'aTable' => [
739 'ctrl' => [
740 'iconfile' => 'EXT:myExt/iconfile.gif',
741 ],
742 ],
743 ];
744 $subject = new TcaMigration();
745 $this->assertEquals($expected, $subject->migrate($input));
746 }
747
748 /**
749 * @test
750 */
751 public function migrateSelectFieldRenderType(): void
752 {
753 $input = [
754 'aTable-do-not-migrate-because-renderType-is-set' => [
755 'columns' => [
756 'a-column' => [
757 'config' => [
758 'type' => 'select',
759 'renderType' => 'fooBar'
760 ]
761 ]
762 ],
763 ],
764 'aTable-do-migrate-because-renderType-is-not-set' => [
765 'columns' => [
766 'a-tree-column' => [
767 'config' => [
768 'type' => 'select',
769 'renderMode' => 'tree'
770 ]
771 ],
772 'a-singlebox-column' => [
773 'config' => [
774 'type' => 'select',
775 'renderMode' => 'singlebox'
776 ]
777 ],
778 'a-checkbox-column' => [
779 'config' => [
780 'type' => 'select',
781 'renderMode' => 'checkbox'
782 ]
783 ],
784 'an-unknown-column' => [
785 'config' => [
786 'type' => 'select',
787 'renderMode' => 'unknown'
788 ]
789 ],
790 'a-maxitems-column-not-set' => [
791 'config' => [
792 'type' => 'select',
793 ]
794 ],
795 'a-maxitems-column-0' => [
796 'config' => [
797 'type' => 'select',
798 'maxitems' => '0'
799 ]
800 ],
801 'a-maxitems-column-1' => [
802 'config' => [
803 'type' => 'select',
804 'maxitems' => '1'
805 ]
806 ],
807 'a-maxitems-column-2' => [
808 'config' => [
809 'type' => 'select',
810 'maxitems' => '2'
811 ]
812 ],
813 'a-tree-column-with-maxitems' => [
814 'config' => [
815 'type' => 'select',
816 'renderMode' => 'tree',
817 'maxitems' => '1'
818 ]
819 ],
820 'a-singlebox-column-with-maxitems' => [
821 'config' => [
822 'type' => 'select',
823 'renderMode' => 'singlebox',
824 'maxitems' => '1'
825 ]
826 ],
827 'a-checkbox-column-with-maxitems' => [
828 'config' => [
829 'type' => 'select',
830 'renderMode' => 'checkbox',
831 'maxitems' => '1'
832 ]
833 ],
834 ],
835 ],
836 ];
837 $expected = [
838 'aTable-do-not-migrate-because-renderType-is-set' => [
839 'columns' => [
840 'a-column' => [
841 'config' => [
842 'type' => 'select',
843 'renderType' => 'fooBar'
844 ]
845 ]
846 ],
847 ],
848 'aTable-do-migrate-because-renderType-is-not-set' => [
849 'columns' => [
850 'a-tree-column' => [
851 'config' => [
852 'type' => 'select',
853 'renderMode' => 'tree',
854 'renderType' => 'selectTree'
855 ]
856 ],
857 'a-singlebox-column' => [
858 'config' => [
859 'type' => 'select',
860 'renderMode' => 'singlebox',
861 'renderType' => 'selectSingleBox'
862 ]
863 ],
864 'a-checkbox-column' => [
865 'config' => [
866 'type' => 'select',
867 'renderMode' => 'checkbox',
868 'renderType' => 'selectCheckBox'
869 ]
870 ],
871 'an-unknown-column' => [
872 'config' => [
873 'type' => 'select',
874 'renderMode' => 'unknown'
875 ]
876 ],
877 'a-maxitems-column-not-set' => [
878 'config' => [
879 'type' => 'select',
880 'renderType' => 'selectSingle'
881 ]
882 ],
883 'a-maxitems-column-0' => [
884 'config' => [
885 'type' => 'select',
886 'maxitems' => '0',
887 'renderType' => 'selectSingle'
888 ]
889 ],
890 'a-maxitems-column-1' => [
891 'config' => [
892 'type' => 'select',
893 'maxitems' => 1,
894 'renderType' => 'selectSingle'
895 ]
896 ],
897 'a-maxitems-column-2' => [
898 'config' => [
899 'type' => 'select',
900 'maxitems' => 2,
901 'renderType' => 'selectMultipleSideBySide'
902 ]
903 ],
904 'a-tree-column-with-maxitems' => [
905 'config' => [
906 'type' => 'select',
907 'renderMode' => 'tree',
908 'renderType' => 'selectTree',
909 'maxitems' => '1'
910 ]
911 ],
912 'a-singlebox-column-with-maxitems' => [
913 'config' => [
914 'type' => 'select',
915 'renderMode' => 'singlebox',
916 'renderType' => 'selectSingleBox',
917 'maxitems' => '1'
918 ]
919 ],
920 'a-checkbox-column-with-maxitems' => [
921 'config' => [
922 'type' => 'select',
923 'renderMode' => 'checkbox',
924 'renderType' => 'selectCheckBox',
925 'maxitems' => '1'
926 ]
927 ],
928 ],
929 ],
930 ];
931 $subject = new TcaMigration();
932 $this->assertEquals($expected, $subject->migrate($input));
933 }
934
935 /**
936 * @return array
937 */
938 public function migrateSetsShowIconTableIfMissingDataProvider(): array
939 {
940 return [
941 'not-a-select-is-kept' => [
942 [
943 // Given config section
944 'type' => 'input',
945 ],
946 [
947 // Expected config section
948 'type' => 'input',
949 ],
950 ],
951 'not-a-selectSingle-is-kept' => [
952 [
953 'type' => 'select',
954 'renderType' => 'selectCheckBox',
955 ],
956 [
957 'type' => 'select',
958 'renderType' => 'selectCheckBox',
959 ],
960 ],
961 'noIconsBelowSelect-true-is-removed' => [
962 [
963 'type' => 'select',
964 'renderType' => 'selectSingle',
965 'noIconsBelowSelect' => true,
966 ],
967 [
968 'type' => 'select',
969 'renderType' => 'selectSingle',
970 ],
971 ],
972 'noIconsBelowSelect-false-is-removed-sets-field-wizard' => [
973 [
974 'type' => 'select',
975 'renderType' => 'selectSingle',
976 'noIconsBelowSelect' => false,
977 ],
978 [
979 'type' => 'select',
980 'renderType' => 'selectSingle',
981 'fieldWizard' => [
982 'selectIcons' => [
983 'disabled' => false,
984 ],
985 ],
986 ],
987 ],
988 'noIconsBelowSelect-false-is-removes-given-showIconTable-false' => [
989 [
990 'type' => 'select',
991 'renderType' => 'selectSingle',
992 'noIconsBelowSelect' => false,
993 'showIconTable' => false,
994 ],
995 [
996 'type' => 'select',
997 'renderType' => 'selectSingle',
998 ],
999 ],
1000 'suppress-icons-1-is-removed' => [
1001 [
1002 'type' => 'select',
1003 'renderType' => 'selectSingle',
1004 'suppress_icons' => '1',
1005 ],
1006 [
1007 'type' => 'select',
1008 'renderType' => 'selectSingle',
1009 ],
1010 ],
1011 'suppress-icons-value-is-removed' => [
1012 [
1013 'type' => 'select',
1014 'renderType' => 'selectSingle',
1015 'suppress_icons' => 'IF_VALUE_FALSE',
1016 ],
1017 [
1018 'type' => 'select',
1019 'renderType' => 'selectSingle',
1020 ],
1021 ],
1022 'selicon-cols-is-removed' => [
1023 [
1024 'type' => 'select',
1025 'renderType' => 'selectSingle',
1026 'selicon_cols' => 16,
1027 ],
1028 [
1029 'type' => 'select',
1030 'renderType' => 'selectSingle',
1031 ],
1032 ],
1033 'foreign_table_loadIcons-is-removed' => [
1034 [
1035 'type' => 'select',
1036 'renderType' => 'selectSingle',
1037 'foreign_table_loadIcons' => true,
1038 ],
1039 [
1040 'type' => 'select',
1041 'renderType' => 'selectSingle',
1042 ],
1043 ],
1044 ];
1045 }
1046
1047 /**
1048 * @test
1049 * @dataProvider migrateSetsShowIconTableIfMissingDataProvider
1050 * @param array $givenConfig
1051 * @param array $expectedConfig
1052 */
1053 public function migrateSetsShowIconTableIfMissing(array $givenConfig, array $expectedConfig): void
1054 {
1055 $input = [
1056 'aTable' => [
1057 'columns' => [
1058 'aField' => [
1059 'config' => $givenConfig,
1060 ]
1061 ],
1062 ],
1063 ];
1064 $expected = $input;
1065 $expected['aTable']['columns']['aField']['config'] = $expectedConfig;
1066
1067 $subject = new TcaMigration();
1068 $this->assertEquals($expected, $subject->migrate($input));
1069 }
1070
1071 /**
1072 * @test
1073 */
1074 public function migrateFixesReferenceToLinkHandler()
1075 {
1076 $input = [
1077 'aTable' => [
1078 'columns' => [
1079 'aCol' => [
1080 'config' => [
1081 'type' => 'input',
1082 'wizards' => [
1083 'link' => [
1084 'module' => [
1085 'name' => 'wizard_element_browser',
1086 'urlParameters' => [
1087 'mode' => 'wizard'
1088 ]
1089 ],
1090 ],
1091 ],
1092 ],
1093 ],
1094 ],
1095 ],
1096 ];
1097 $expected = [
1098 'aTable' => [
1099 'columns' => [
1100 'aCol' => [
1101 'config' => [
1102 'type' => 'input',
1103 'wizards' => [
1104 'link' => [
1105 'module' => [
1106 'name' => 'wizard_link',
1107 ],
1108 ],
1109 ],
1110 ],
1111 ],
1112 ],
1113 ],
1114 ];
1115
1116 $subject = new TcaMigration();
1117 $this->assertEquals($expected, $subject->migrate($input));
1118 }
1119
1120 /**
1121 * @return array
1122 */
1123 public function migrateRemovesRteTransformOptionsDataProvider(): array
1124 {
1125 return [
1126 'columns richtext configuration' => [
1127 [
1128 // Given config section
1129 'aTable' => [
1130 'columns' => [
1131 'aField' => [
1132 'config' => [
1133 'type' => 'text',
1134 ],
1135 'defaultExtras' => 'richtext:rte_transform[]'
1136 ]
1137 ]
1138 ]
1139 ],
1140 [
1141 // Expected config section
1142 'aTable' => [
1143 'columns' => [
1144 'aField' => [
1145 'config' => [
1146 'type' => 'text',
1147 'enableRichtext' => true,
1148 'richtextConfiguration' => 'default',
1149 ],
1150 ]
1151 ]
1152 ]
1153 ],
1154 ],
1155 'columns richtext configuration without bracket' => [
1156 [
1157 'aTable' => [
1158 'columns' => [
1159 'aField' => [
1160 'config' => [
1161 'type' => 'text',
1162 ],
1163 'defaultExtras' => 'richtext:rte_transform'
1164 ]
1165 ]
1166 ]
1167 ],
1168 [
1169 'aTable' => [
1170 'columns' => [
1171 'aField' => [
1172 'config' => [
1173 'type' => 'text',
1174 'enableRichtext' => true,
1175 'richtextConfiguration' => 'default',
1176 ],
1177 ]
1178 ]
1179 ]
1180 ],
1181 ],
1182 'columns richtext with mode' => [
1183 [
1184 'aTable' => [
1185 'columns' => [
1186 'aField' => [
1187 'config' => [
1188 'type' => 'text',
1189 ],
1190 'defaultExtras' => 'richtext:rte_transform[mode=ts_css]'
1191 ]
1192 ]
1193 ]
1194 ],
1195 [
1196 'aTable' => [
1197 'columns' => [
1198 'aField' => [
1199 'config' => [
1200 'type' => 'text',
1201 'enableRichtext' => true,
1202 'richtextConfiguration' => 'default',
1203 ],
1204 ]
1205 ]
1206 ]
1207 ],
1208 ],
1209 'columns richtext with mode and others' => [
1210 [
1211 'aTable' => [
1212 'columns' => [
1213 'aField' => [
1214 'config' => [
1215 'type' => 'text',
1216 ],
1217 'defaultExtras' => 'richtext:rte_transform[flag=rte_enabled|mode=ts_css]'
1218 ]
1219 ]
1220 ]
1221 ],
1222 [
1223 'aTable' => [
1224 'columns' => [
1225 'aField' => [
1226 'config' => [
1227 'type' => 'text',
1228 'enableRichtext' => true,
1229 'richtextConfiguration' => 'default',
1230 ],
1231 ]
1232 ]
1233 ]
1234 ],
1235 ],
1236 'columns richtext with array with mode and others' => [
1237 [
1238 'aTable' => [
1239 'columns' => [
1240 'aField' => [
1241 'config' => [
1242 'type' => 'text',
1243 ],
1244 'defaultExtras' => 'richtext[]:rte_transform[flag=rte_enabled|mode=ts_css]'
1245 ]
1246 ]
1247 ]
1248 ],
1249 [
1250 'aTable' => [
1251 'columns' => [
1252 'aField' => [
1253 'config' => [
1254 'type' => 'text',
1255 'enableRichtext' => true,
1256 'richtextConfiguration' => 'default',
1257 ],
1258 ]
1259 ]
1260 ]
1261 ],
1262 ],
1263 'columns richtext * with mode and others' => [
1264 [
1265 'aTable' => [
1266 'columns' => [
1267 'aField' => [
1268 'config' => [
1269 'type' => 'text',
1270 ],
1271 'defaultExtras' => 'richtext[*]:rte_transform[flag=rte_enabled|mode=ts_css]'
1272 ]
1273 ]
1274 ]
1275 ],
1276 [
1277 'aTable' => [
1278 'columns' => [
1279 'aField' => [
1280 'config' => [
1281 'type' => 'text',
1282 'enableRichtext' => true,
1283 'richtextConfiguration' => 'default',
1284 ],
1285 ]
1286 ]
1287 ]
1288 ],
1289 ],
1290 'columns richtext cut-copy-paste with mode and others' => [
1291 [
1292 'aTable' => [
1293 'columns' => [
1294 'aField' => [
1295 'config' => [
1296 'type' => 'text',
1297 ],
1298 'defaultExtras' => 'richtext[cut|copy|paste]:rte_transform[flag=rte_enabled|mode=ts_css]'
1299 ]
1300 ]
1301 ]
1302 ],
1303 [
1304 'aTable' => [
1305 'columns' => [
1306 'aField' => [
1307 'config' => [
1308 'type' => 'text',
1309 'enableRichtext' => true,
1310 'richtextConfiguration' => 'default',
1311 ],
1312 ]
1313 ]
1314 ]
1315 ],
1316 ],
1317 'columnsOverrides richtext with brackets' => [
1318 [
1319 'aTable' => [
1320 'columns' => [
1321 'aField' => [
1322 'config' => [
1323 'type' => 'text',
1324 ],
1325 ],
1326 ],
1327 'types' => [
1328 'aType' => [
1329 'columnsOverrides' => [
1330 'aField' => [
1331 'defaultExtras' => 'richtext:rte_transform[]'
1332 ]
1333 ]
1334 ]
1335 ]
1336 ]
1337 ],
1338 [
1339 'aTable' => [
1340 'columns' => [
1341 'aField' => [
1342 'config' => [
1343 'type' => 'text',
1344 ],
1345 ],
1346 ],
1347 'types' => [
1348 'aType' => [
1349 'columnsOverrides' => [
1350 'aField' => [
1351 'config' => [
1352 'enableRichtext' => true,
1353 'richtextConfiguration' => 'default',
1354 ],
1355 ]
1356 ]
1357 ]
1358 ]
1359 ]
1360 ],
1361 ],
1362 'columnsOverrides richtext' => [
1363 [
1364 'aTable' => [
1365 'columns' => [
1366 'aField' => [
1367 'config' => [
1368 'type' => 'text',
1369 ],
1370 ],
1371 ],
1372 'types' => [
1373 'aType' => [
1374 'columnsOverrides' => [
1375 'aField' => [
1376 'defaultExtras' => 'richtext:rte_transform'
1377 ]
1378 ]
1379 ]
1380 ]
1381 ]
1382 ],
1383 [
1384 'aTable' => [
1385 'columns' => [
1386 'aField' => [
1387 'config' => [
1388 'type' => 'text',
1389 ],
1390 ],
1391 ],
1392 'types' => [
1393 'aType' => [
1394 'columnsOverrides' => [
1395 'aField' => [
1396 'config' => [
1397 'enableRichtext' => true,
1398 'richtextConfiguration' => 'default',
1399 ],
1400 ]
1401 ]
1402 ]
1403 ]
1404 ]
1405 ],
1406 ],
1407 'columnsOverrides richtext with defalut mode' => [
1408 [
1409 'aTable' => [
1410 'columns' => [
1411 'aField' => [
1412 'config' => [
1413 'type' => 'text',
1414 ],
1415 ],
1416 ],
1417 'types' => [
1418 'aType' => [
1419 'columnsOverrides' => [
1420 'aField' => [
1421 'defaultExtras' => 'richtext:rte_transform[mode=ts_css]'
1422 ]
1423 ]
1424 ]
1425 ]
1426 ]
1427 ],
1428 [
1429 'aTable' => [
1430 'columns' => [
1431 'aField' => [
1432 'config' => [
1433 'type' => 'text',
1434 ],
1435 ],
1436 ],
1437 'types' => [
1438 'aType' => [
1439 'columnsOverrides' => [
1440 'aField' => [
1441 'config' => [
1442 'enableRichtext' => true,
1443 'richtextConfiguration' => 'default',
1444 ],
1445 ]
1446 ]
1447 ]
1448 ]
1449 ]
1450 ],
1451 ],
1452 'columnsOverrides richtext with mode and others' => [
1453 [
1454 'aTable' => [
1455 'columns' => [
1456 'aField' => [
1457 'config' => [
1458 'type' => 'text',
1459 ],
1460 ],
1461 ],
1462 'types' => [
1463 'aType' => [
1464 'columnsOverrides' => [
1465 'aField' => [
1466 'defaultExtras' => 'richtext:rte_transform[flag=rte_enabled|mode=ts_css]'
1467 ]
1468 ]
1469 ]
1470 ]
1471 ]
1472 ],
1473 [
1474 'aTable' => [
1475 'columns' => [
1476 'aField' => [
1477 'config' => [
1478 'type' => 'text',
1479 ],
1480 ],
1481 ],
1482 'types' => [
1483 'aType' => [
1484 'columnsOverrides' => [
1485 'aField' => [
1486 'config' => [
1487 'enableRichtext' => true,
1488 'richtextConfiguration' => 'default',
1489 ],
1490 ]
1491 ]
1492 ]
1493 ]
1494 ]
1495 ],
1496 ],
1497 'columnsOverrides richtext brackets mode and others' => [
1498 [
1499 'aTable' => [
1500 'columns' => [
1501 'aField' => [
1502 'config' => [
1503 'type' => 'text',
1504 ],
1505 ],
1506 ],
1507 'types' => [
1508 'aType' => [
1509 'columnsOverrides' => [
1510 'aField' => [
1511 'defaultExtras' => 'richtext[]:rte_transform[flag=rte_enabled|mode=ts_css]'
1512 ]
1513 ]
1514 ]
1515 ]
1516 ]
1517 ],
1518 [
1519 'aTable' => [
1520 'columns' => [
1521 'aField' => [
1522 'config' => [
1523 'type' => 'text',
1524 ],
1525 ],
1526 ],
1527 'types' => [
1528 'aType' => [
1529 'columnsOverrides' => [
1530 'aField' => [
1531 'config' => [
1532 'enableRichtext' => true,
1533 'richtextConfiguration' => 'default',
1534 ],
1535 ]
1536 ]
1537 ]
1538 ]
1539 ]
1540 ],
1541 ],
1542 'columnsOverrides richtext star with mode and others' => [
1543 [
1544 'aTable' => [
1545 'columns' => [
1546 'aField' => [
1547 'config' => [
1548 'type' => 'text',
1549 ],
1550 ],
1551 ],
1552 'types' => [
1553 'aType' => [
1554 'columnsOverrides' => [
1555 'aField' => [
1556 'defaultExtras' => 'richtext[*]:rte_transform[flag=rte_enabled|mode=ts_css]'
1557 ]
1558 ]
1559 ]
1560 ]
1561 ]
1562 ],
1563 [
1564 'aTable' => [
1565 'columns' => [
1566 'aField' => [
1567 'config' => [
1568 'type' => 'text',
1569 ],
1570 ],
1571 ],
1572 'types' => [
1573 'aType' => [
1574 'columnsOverrides' => [
1575 'aField' => [
1576 'config' => [
1577 'enableRichtext' => true,
1578 'richtextConfiguration' => 'default',
1579 ],
1580 ]
1581 ]
1582 ]
1583 ]
1584 ]
1585 ],
1586 ],
1587 'columnsOverrides richtext cut-copy-paste ith mode and others' => [
1588 [
1589 'aTable' => [
1590 'columns' => [
1591 'aField' => [
1592 'config' => [
1593 'type' => 'text',
1594 ],
1595 ],
1596 ],
1597 'types' => [
1598 'aType' => [
1599 'columnsOverrides' => [
1600 'aField' => [
1601 'defaultExtras' => 'richtext[copy|cut|paste]:rte_transform[flag=rte_enabled|mode=ts_css]'
1602 ]
1603 ]
1604 ]
1605 ]
1606 ]
1607 ],
1608 [
1609 'aTable' => [
1610 'columns' => [
1611 'aField' => [
1612 'config' => [
1613 'type' => 'text',
1614 ],
1615 ],
1616 ],
1617 'types' => [
1618 'aType' => [
1619 'columnsOverrides' => [
1620 'aField' => [
1621 'config' => [
1622 'enableRichtext' => true,
1623 'richtextConfiguration' => 'default',
1624 ],
1625 ]
1626 ]
1627 ]
1628 ]
1629 ]
1630 ],
1631 ],
1632 ];
1633 }
1634
1635 /**
1636 * @test
1637 * @dataProvider migrateRemovesRteTransformOptionsDataProvider
1638 * @param array $givenConfig
1639 * @param array $expectedConfig
1640 */
1641 public function migrateRemovesRteTransformOptions(array $givenConfig, array $expectedConfig): void
1642 {
1643 $subject = new TcaMigration();
1644 $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
1645 }
1646
1647 /**
1648 * @return array
1649 */
1650 public function migrateSelectTreeOptionsDataProvider(): array
1651 {
1652 return [
1653 'remove width' => [
1654 [
1655 // Given config section
1656 'aTable' => [
1657 'columns' => [
1658 'aField' => [
1659 'config' => [
1660 'type' => 'select',
1661 'renderType' => 'selectTree',
1662 'treeConfig' => [
1663 'appearance' => [
1664 'width' => 200
1665 ]
1666 ]
1667 ]
1668 ]
1669 ]
1670 ]
1671 ],
1672 [
1673 // Expected config section
1674 'aTable' => [
1675 'columns' => [
1676 'aField' => [
1677 'config' => [
1678 'type' => 'select',
1679 'renderType' => 'selectTree',
1680 'treeConfig' => [
1681 'appearance' => [
1682 ]
1683 ]
1684 ]
1685 ]
1686 ]
1687 ]
1688 ]
1689 ],
1690 'remove allowRecursiveMode' => [
1691 [
1692 // Given config section
1693 'aTable' => [
1694 'columns' => [
1695 'aField' => [
1696 'config' => [
1697 'type' => 'select',
1698 'renderType' => 'selectTree',
1699 'treeConfig' => [
1700 'appearance' => [
1701 'someKey' => 'value',
1702 'allowRecursiveMode' => true
1703 ]
1704 ]
1705 ]
1706 ]
1707 ]
1708 ]
1709 ],
1710 [
1711 // Expected config section
1712 'aTable' => [
1713 'columns' => [
1714 'aField' => [
1715 'config' => [
1716 'type' => 'select',
1717 'renderType' => 'selectTree',
1718 'treeConfig' => [
1719 'appearance' => [
1720 'someKey' => 'value'
1721 ]
1722 ]
1723 ]
1724 ]
1725 ]
1726 ]
1727 ]
1728 ],
1729 'move autoSizeMax to size' => [
1730 [
1731 // Given config section
1732 'aTable' => [
1733 'columns' => [
1734 'aField' => [
1735 'config' => [
1736 'type' => 'select',
1737 'renderType' => 'selectTree',
1738 'autoSizeMax' => 20,
1739 'size' => 10
1740 ]
1741 ]
1742 ]
1743 ]
1744 ],
1745 [
1746 // Expected config section
1747 'aTable' => [
1748 'columns' => [
1749 'aField' => [
1750 'config' => [
1751 'type' => 'select',
1752 'renderType' => 'selectTree',
1753 'size' => 20
1754 ]
1755 ]
1756 ]
1757 ]
1758 ]
1759 ],
1760 'keep settings for non selectTree' => [
1761 [
1762 // Given config section
1763 'aTable' => [
1764 'columns' => [
1765 'aField' => [
1766 'config' => [
1767 'type' => 'select',
1768 'renderType' => 'not a select tree',
1769 'autoSizeMax' => 20,
1770 'size' => 10,
1771 'treeConfig' => [
1772 'appearance' => [
1773 'someKey' => 'value',
1774 'allowRecursiveMode' => true,
1775 'width' => 200
1776 ]
1777 ]
1778 ]
1779 ]
1780 ]
1781 ]
1782 ],
1783 [
1784 // Expected config section
1785 'aTable' => [
1786 'columns' => [
1787 'aField' => [
1788 'config' => [
1789 'type' => 'select',
1790 'renderType' => 'not a select tree',
1791 'autoSizeMax' => 20,
1792 'size' => 10,
1793 'treeConfig' => [
1794 'appearance' => [
1795 'someKey' => 'value',
1796 'allowRecursiveMode' => true,
1797 'width' => 200
1798 ]
1799 ]
1800 ]
1801 ]
1802 ]
1803 ]
1804 ]
1805 ]
1806 ];
1807 }
1808
1809 /**
1810 * @test
1811 * @dataProvider migrateSelectTreeOptionsDataProvider
1812 * @param array $input
1813 * @param array $expected
1814 */
1815 public function migrateSelectTreeOptions(array $input, array $expected): void
1816 {
1817 $subject = new TcaMigration();
1818 $this->assertEquals($expected, $subject->migrate($input));
1819 }
1820
1821 /**
1822 * @return array
1823 */
1824 public function migrateTsTemplateSoftReferencesDataProvider(): array
1825 {
1826 return [
1827 'nothing removed' => [
1828 [
1829 'aTable' => [
1830 'columns' => [
1831 'aCol' => [
1832 'config' => [
1833 'type' => 'input',
1834 'softref' => 'email,somethingelse'
1835 ],
1836 ],
1837 ],
1838 ],
1839 ],
1840 [
1841 'aTable' => [
1842 'columns' => [
1843 'aCol' => [
1844 'config' => [
1845 'type' => 'input',
1846 'softref' => 'email,somethingelse',
1847 ],
1848 ],
1849 ],
1850 ],
1851 ]
1852 ],
1853 'TStemplate only' => [
1854 [
1855 'aTable' => [
1856 'columns' => [
1857 'aCol' => [
1858 'config' => [
1859 'type' => 'input',
1860 'softref' => 'TStemplate,somethingelse'
1861 ],
1862 ],
1863 ],
1864 ],
1865 ],
1866 [
1867 'aTable' => [
1868 'columns' => [
1869 'aCol' => [
1870 'config' => [
1871 'type' => 'input',
1872 'softref' => 'somethingelse',
1873 ],
1874 ],
1875 ],
1876 ],
1877 ]
1878 ],
1879 'TStemplate and TSconfig' => [
1880 [
1881 'aTable' => [
1882 'columns' => [
1883 'aCol' => [
1884 'config' => [
1885 'type' => 'input',
1886 'softref' => 'TStemplate,somethingelse,TSconfig'
1887 ],
1888 ],
1889 ],
1890 ],
1891 ],
1892 [
1893 'aTable' => [
1894 'columns' => [
1895 'aCol' => [
1896 'config' => [
1897 'type' => 'input',
1898 'softref' => 'somethingelse',
1899 ],
1900 ],
1901 ],
1902 ],
1903 ]
1904 ],
1905 ];
1906 }
1907
1908 /**
1909 * @test
1910 * @dataProvider migrateTsTemplateSoftReferencesDataProvider
1911 * @param array $givenConfig
1912 * @param array $expectedConfig
1913 */
1914 public function migrateTsTemplateSoftReferences(array $givenConfig, array $expectedConfig): void
1915 {
1916 $subject = new TcaMigration();
1917 $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
1918 }
1919
1920 /**
1921 * @return array
1922 */
1923 public function migrateShowIfRTESettingDataProvider(): array
1924 {
1925 return [
1926 'nothing removed' => [
1927 [
1928 'aTable' => [
1929 'columns' => [
1930 'aCol' => [
1931 'config' => [
1932 'type' => 'check'
1933 ],
1934 ],
1935 ],
1936 ],
1937 ],
1938 [
1939 'aTable' => [
1940 'columns' => [
1941 'aCol' => [
1942 'config' => [
1943 'type' => 'check'
1944 ],
1945 ],
1946 ],
1947 ],
1948 ]
1949 ],
1950 'Option removed' => [
1951 [
1952 'aTable' => [
1953 'columns' => [
1954 'aCol' => [
1955 'config' => [
1956 'type' => 'check',
1957 'showIfRTE' => false
1958 ],
1959 ],
1960 ],
1961 ],
1962 ],
1963 [
1964 'aTable' => [
1965 'columns' => [
1966 'aCol' => [
1967 'config' => [
1968 'type' => 'check'
1969 ],
1970 ],
1971 ],
1972 ],
1973 ]
1974
1975 ],
1976 ];
1977 }
1978
1979 /**
1980 * @test
1981 * @dataProvider migrateShowIfRTESettingDataProvider
1982 * @param array $givenConfig
1983 * @param array $expectedConfig
1984 */
1985 public function migrateShowIfRTESetting(array $givenConfig, array $expectedConfig): void
1986 {
1987 $subject = new TcaMigration();
1988 $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
1989 }
1990
1991 /**
1992 * @return array
1993 */
1994 public function migrateWorkspaceSettingsDataProvider(): array
1995 {
1996 return [
1997 'no workspaces enabled' => [
1998 [
1999 'aTable' => [
2000 'ctrl' => [
2001 'versioningWS' => false
2002 ],
2003 ],
2004 ],
2005 [
2006 'aTable' => [
2007 'ctrl' => [
2008 'versioningWS' => false
2009 ],
2010 ],
2011 ]
2012 ],
2013 'nothing activated' => [
2014 [
2015 'aTable' => [
2016 'ctrl' => [
2017 'label' => 'blabla'
2018 ],
2019 ],
2020 ],
2021 [
2022 'aTable' => [
2023 'ctrl' => [
2024 'label' => 'blabla'
2025 ],
2026 ],
2027 ]
2028 ],
2029 'nothing changed, workspaces enabled' => [
2030 [
2031 'aTable' => [
2032 'ctrl' => [
2033 'versioningWS' => true
2034 ],
2035 ],
2036 ],
2037 [
2038 'aTable' => [
2039 'ctrl' => [
2040 'versioningWS' => true
2041 ],
2042 ],
2043 ]
2044 ],
2045 'cast workspaces to bool' => [
2046 [
2047 'aTable' => [
2048 'ctrl' => [
2049 'versioningWS' => 1
2050 ],
2051 ],
2052 ],
2053 [
2054 'aTable' => [
2055 'ctrl' => [
2056 'versioningWS' => true
2057 ],
2058 ],
2059 ]
2060 ],
2061 'cast workspaces v2 to bool' => [
2062 [
2063 'aTable' => [
2064 'ctrl' => [
2065 'versioningWS' => 2
2066 ],
2067 ],
2068 ],
2069 [
2070 'aTable' => [
2071 'ctrl' => [
2072 'versioningWS' => true
2073 ],
2074 ],
2075 ]
2076 ],
2077 'cast workspaces v2 to bool and remove followpages' => [
2078 [
2079 'aTable' => [
2080 'ctrl' => [
2081 'versioningWS' => 2,
2082 'versioning_followPages' => true
2083 ],
2084 ],
2085 ],
2086 [
2087 'aTable' => [
2088 'ctrl' => [
2089 'versioningWS' => true
2090 ],
2091 ],
2092 ]
2093 ],
2094 ];
2095 }
2096
2097 /**
2098 * @test
2099 * @dataProvider migrateWorkspaceSettingsDataProvider
2100 * @param array $givenConfig
2101 * @param array $expectedConfig
2102 */
2103 public function migrateWorkspaceSettings(array $givenConfig, array $expectedConfig): void
2104 {
2105 $subject = new TcaMigration();
2106 $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
2107 }
2108
2109 /**
2110 * @return array
2111 */
2112 public function migrateTranslationTableDataProvider(): array
2113 {
2114 return [
2115 'remove transForeignTable' => [
2116 [
2117 'aTable' => [
2118 'ctrl' => [
2119 'transForeignTable' => 'pages_language_overlay',
2120 ],
2121 ],
2122 ],
2123 [
2124 'aTable' => [
2125 'ctrl' => [],
2126 ],
2127 ]
2128 ],
2129 'remove transOrigPointerTable' => [
2130 [
2131 'aTable' => [
2132 'ctrl' => [
2133 'transOrigPointerTable' => 'pages',
2134 ],
2135 ],
2136 ],
2137 [
2138 'aTable' => [
2139 'ctrl' => [],
2140 ],
2141 ]
2142 ]
2143 ];
2144 }
2145
2146 /**
2147 * @param array $givenConfig
2148 * @param array $expectedConfig
2149 * @test
2150 * @dataProvider migrateTranslationTableDataProvider
2151 */
2152 public function migrateTranslationTable(array $givenConfig, array $expectedConfig): void
2153 {
2154 $subject = new TcaMigration();
2155 $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
2156 }
2157
2158 /**
2159 * @return array
2160 */
2161 public function migrateL10nModeDefinitionsDataProvider(): array
2162 {
2163 return [
2164 'remove l10n_mode noCopy' => [
2165 [
2166 'aTable' => [
2167 'columns' => [
2168 'aColumn' => [
2169 'l10n_mode' => 'noCopy',
2170 'config' => [
2171 'type' => 'text',
2172 ],
2173 ],
2174 ],
2175 ],
2176 ],
2177 [
2178 'aTable' => [
2179 'columns' => [
2180 'aColumn' => [
2181 'config' => [
2182 'type' => 'text',
2183 ],
2184 ],
2185 ],
2186 ],
2187 ]
2188 ],
2189 'remove l10n_mode mergeIfNotBlank' => [
2190 [
2191 'aTable' => [
2192 'columns' => [
2193 'aColumn' => [
2194 'l10n_mode' => 'mergeIfNotBlank',
2195 'config' => [
2196 'type' => 'text',
2197 ],
2198 ],
2199 ],
2200 ],
2201 ],
2202 [
2203 'aTable' => [
2204 'columns' => [
2205 'aColumn' => [
2206 'config' => [
2207 'type' => 'text',
2208 'behaviour' => [
2209 'allowLanguageSynchronization' => true,
2210 ]
2211 ]
2212 ],
2213 ],
2214 ],
2215 ]
2216 ],
2217 ];
2218 }
2219
2220 /**
2221 * @param array $givenConfig
2222 * @param array $expectedConfig
2223 * @test
2224 * @dataProvider migrateL10nModeDefinitionsDataProvider
2225 */
2226 public function migrateL10nModeDefinitions(array $givenConfig, array $expectedConfig): void
2227 {
2228 $subject = new TcaMigration();
2229 $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
2230 }
2231
2232 /**
2233 * @return array
2234 */
2235 public function migratePageLocalizationDefinitionsDataProvider(): array
2236 {
2237 return [
2238 'missing l10n_mode' => [
2239 [
2240 'pages' => [
2241 'columns' => [
2242 'aColumn' => [
2243 'config' => [
2244 'type' => 'input',
2245 ],
2246 ],
2247 ],
2248 ],
2249 'pages_language_overlay' => [
2250 'columns' => [
2251 'aColumn' => [
2252 'config' => [
2253 'type' => 'input',
2254 ],
2255 'l10n_mode' => 'any-possible-value',
2256 ],
2257 ],
2258 ],
2259 ],
2260 [
2261 'pages' => [
2262 'columns' => [
2263 'aColumn' => [
2264 'config' => [
2265 'type' => 'input',
2266 ],
2267 'l10n_mode' => 'any-possible-value',
2268 ],
2269 ],
2270 ],
2271 ]
2272 ],
2273 'missing allowLanguageSynchronization' => [
2274 [
2275 'pages' => [
2276 'columns' => [
2277 'aColumn' => [
2278 'config' => [
2279 'type' => 'input',
2280 ],
2281 ],
2282 ],
2283 ],
2284 'pages_language_overlay' => [
2285 'columns' => [
2286 'aColumn' => [
2287 'config' => [
2288 'type' => 'input',
2289 'behaviour' => [
2290 'allowLanguageSynchronization' => true,
2291 ]
2292 ],
2293 ],
2294 ],
2295 ],
2296 ],
2297 [
2298 'pages' => [
2299 'columns' => [
2300 'aColumn' => [
2301 'config' => [
2302 'type' => 'input',
2303 'behaviour' => [
2304 'allowLanguageSynchronization' => true,
2305 ]
2306 ],
2307 ],
2308 ],
2309 ],
2310 ]
2311 ],
2312 ];
2313 }
2314
2315 /**
2316 * @param array $givenConfig
2317 * @param array $expectedConfig
2318 * @test
2319 * @dataProvider migratePageLocalizationDefinitionsDataProvider
2320 */
2321 public function migratePageLocalizationDefinitions(array $givenConfig, array $expectedConfig): void
2322 {
2323 $subject = new TcaMigration();
2324 $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
2325 }
2326
2327 /**
2328 * @return array
2329 */
2330 public function migrateInlineLocalizationModeDataProvider(): array
2331 {
2332 return [
2333 'remove counter-productive localizationMode=keep' => [
2334 [
2335 'aTable' => [
2336 'columns' => [
2337 'aColumn' => [
2338 'config' => [
2339 'type' => 'inline',
2340 'behaviour' => [
2341 'localizationMode' => 'keep',
2342 'allowLanguageSynchronization' => true,
2343 ],
2344 ]
2345 ],
2346 ],
2347 ],
2348 ],
2349 [
2350 'aTable' => [
2351 'columns' => [
2352 'aColumn' => [
2353 'config' => [
2354 'type' => 'inline',
2355 'behaviour' => [
2356 'allowLanguageSynchronization' => true,
2357 ],
2358 ],
2359 ],
2360 ],
2361 ],
2362 ]
2363 ],
2364 'keep deprecated localizationMode=keep' => [
2365 [
2366 'aTable' => [
2367 'columns' => [
2368 'aColumn' => [
2369 'config' => [
2370 'type' => 'inline',
2371 'behaviour' => [
2372 'localizationMode' => 'keep',
2373 ],
2374 ],
2375 ],
2376 ],
2377 ],
2378 ],
2379 [
2380 'aTable' => [
2381 'columns' => [
2382 'aColumn' => [
2383 'config' => [
2384 'type' => 'inline',
2385 'behaviour' => [
2386 'localizationMode' => 'keep',
2387 ],
2388 ]
2389 ],
2390 ],
2391 ],
2392 ]
2393 ],
2394 'keep deprecated localizationMode=select' => [
2395 [
2396 'aTable' => [
2397 'columns' => [
2398 'aColumn' => [
2399 'config' => [
2400 'type' => 'inline',
2401 'behaviour' => [
2402 'localizationMode' => 'select',
2403 ],
2404 ],
2405 ],
2406 ],
2407 ],
2408 ],
2409 [
2410 'aTable' => [
2411 'columns' => [
2412 'aColumn' => [
2413 'config' => [
2414 'type' => 'inline',
2415 'behaviour' => [
2416 'localizationMode' => 'select',
2417 ],
2418 ]
2419 ],
2420 ],
2421 ],
2422 ]
2423 ],
2424 ];
2425 }
2426
2427 /**
2428 * @param array $givenConfig
2429 * @param array $expectedConfig
2430 * @test
2431 * @dataProvider migrateInlineLocalizationModeDataProvider
2432 */
2433 public function migrateInlineLocalizationMode(array $givenConfig, array $expectedConfig): void
2434 {
2435 $subject = new TcaMigration();
2436 $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
2437 $this->assertNotEmpty($subject->getMessages());
2438 }
2439
2440 /**
2441 * @return array
2442 */
2443 public function migrateMovesRequestUpdateCtrlFieldToColumnsDataProvider(): array
2444 {
2445 return [
2446 'move single field name' => [
2447 [
2448 'aTable' => [
2449 'ctrl' => [
2450 'requestUpdate' => 'aField',
2451 ],
2452 'columns' => [
2453 'aField' => [
2454 'label' => 'foo',
2455 'config' => [
2456 'type' => 'input',
2457 ],
2458 ],
2459 ],
2460 ],
2461 ],
2462 [
2463 'aTable' => [
2464 'ctrl' => [],
2465 'columns' => [
2466 'aField' => [
2467 'label' => 'foo',
2468 'config' => [
2469 'type' => 'input',
2470 ],
2471 'onChange' => 'reload',
2472 ],
2473 ],
2474 ],
2475 ],
2476 ],
2477 'ignore missing field but migrate others' => [
2478 [
2479 'aTable' => [
2480 'ctrl' => [
2481 'requestUpdate' => 'aField, bField, cField, ',
2482 ],
2483 'columns' => [
2484 'aField' => [
2485 'config' => [
2486 'type' => 'none',
2487 ],
2488 ],
2489 'cField' => [
2490 'config' => [
2491 'type' => 'none',
2492 ],
2493 ],
2494 ],
2495 ],
2496 ],
2497 [
2498 'aTable' => [
2499 'ctrl' => [],
2500 'columns' => [
2501 'aField' => [
2502 'config' => [
2503 'type' => 'none',
2504 ],
2505 'onChange' => 'reload',
2506 ],
2507 'cField' => [
2508 'config' => [
2509 'type' => 'none',
2510 ],
2511 'onChange' => 'reload',
2512 ],
2513 ],
2514 ],
2515 ],
2516 ],
2517 ];
2518 }
2519
2520 /**
2521 * @param array $input
2522 * @param array $expected
2523 * @test
2524 * @dataProvider migrateMovesRequestUpdateCtrlFieldToColumnsDataProvider
2525 */
2526 public function migrateMovesRequestUpdateCtrlFieldToColumns(array $input, array $expected): void
2527 {
2528 $this->assertEquals($expected, (new TcaMigration())->migrate($input));
2529 }
2530
2531 /**
2532 * @return array
2533 */
2534 public function migrateMovesTypeInputDateTimeToRenderTypeDataProvider(): array
2535 {
2536 return [
2537 'simple input with eval date' => [
2538 [
2539 'aTable' => [
2540 'columns' => [
2541 'aField' => [
2542 'label' => 'foo',
2543 'config' => [
2544 'type' => 'input',
2545 'eval' => 'date',
2546 ],
2547 ],
2548 ],
2549 ],
2550 ],
2551 [
2552 'aTable' => [
2553 'columns' => [
2554 'aField' => [
2555 'label' => 'foo',
2556 'config' => [
2557 'type' => 'input',
2558 'eval' => 'date',
2559 'renderType' => 'inputDateTime',
2560 ],
2561 ],
2562 ],
2563 ],
2564 ]
2565 ],
2566 'simple input with eval datetime' => [
2567 [
2568 'aTable' => [
2569 'columns' => [
2570 'aField' => [
2571 'label' => 'foo',
2572 'config' => [
2573 'type' => 'input',
2574 'eval' => 'datetime',
2575 ],
2576 ],
2577 ],
2578 ],
2579 ],
2580 [
2581 'aTable' => [
2582 'columns' => [
2583 'aField' => [
2584 'label' => 'foo',
2585 'config' => [
2586 'type' => 'input',
2587 'eval' => 'datetime',
2588 'renderType' => 'inputDateTime',
2589 ],
2590 ],
2591 ],
2592 ],
2593 ]
2594 ],
2595 'simple input with eval time' => [
2596 [
2597 'aTable' => [
2598 'columns' => [
2599 'aField' => [
2600 'label' => 'foo',
2601 'config' => [
2602 'type' => 'input',
2603 'eval' => 'time',
2604 ],
2605 ],
2606 ],
2607 ],
2608 ],
2609 [
2610 'aTable' => [
2611 'columns' => [
2612 'aField' => [
2613 'label' => 'foo',
2614 'config' => [
2615 'type' => 'input',
2616 'eval' => 'time',
2617 'renderType' => 'inputDateTime',
2618 ],
2619 ],
2620 ],
2621 ],
2622 ]
2623 ],
2624 'simple input with eval timesec' => [
2625 [
2626 'aTable' => [
2627 'columns' => [
2628 'aField' => [
2629 'label' => 'foo',
2630 'config' => [
2631 'type' => 'input',
2632 'eval' => 'timesec',
2633 ],
2634 ],
2635 ],
2636 ],
2637 ],
2638 [
2639 'aTable' => [
2640 'columns' => [
2641 'aField' => [
2642 'label' => 'foo',
2643 'config' => [
2644 'type' => 'input',
2645 'eval' => 'timesec',
2646 'renderType' => 'inputDateTime',
2647 ],
2648 ],
2649 ],
2650 ],
2651 ]
2652 ],
2653 'input with multiple evals' => [
2654 [
2655 'aTable' => [
2656 'columns' => [
2657 'aField' => [
2658 'label' => 'foo',
2659 'config' => [
2660 'type' => 'input',
2661 'eval' => 'null,date, required',
2662 ],
2663 ],
2664 ],
2665 ],
2666 ],
2667 [
2668 'aTable' => [
2669 'columns' => [
2670 'aField' => [
2671 'label' => 'foo',
2672 'config' => [
2673 'type' => 'input',
2674 'eval' => 'null,date, required',
2675 'renderType' => 'inputDateTime',
2676 ],
2677 ],
2678 ],
2679 ],
2680 ]
2681 ],
2682 ];
2683 }
2684
2685 /**
2686 * @param array $input
2687 * @param array $expected
2688 * @test
2689 * @dataProvider migrateMovesTypeInputDateTimeToRenderTypeDataProvider
2690 */
2691 public function migrateMovesTypeInputDateTimeToRenderType(array $input, array $expected): void
2692 {
2693 $this->assertEquals($expected, (new TcaMigration())->migrate($input));
2694 }
2695
2696 /**
2697 * @return array
2698 */
2699 public function migrateMovesWizardsWithEnableByTypeConfigToColumnsOverridesDataProvider(): array
2700 {
2701 return [
2702 'enableByTypeConfig on multiple wizards' => [
2703 [
2704 'aTable' => [
2705 'columns' => [
2706 'aField' => [
2707 'exclude' => true,
2708 'label' => 'aLabel',
2709 'config' => [
2710 'type' => 'text',
2711 'wizards' => [
2712 'aWizard' => [
2713 'type' => 'aType',
2714 'title' => 'aTitle',
2715 'enableByTypeConfig' => '1',
2716 ],
2717 'anotherWizard' => [
2718 'type' => 'aType',
2719 'title' => 'anotherTitle',
2720 'enableByTypeConfig' => 1,
2721 ],
2722 'yetAnotherWizard' => [
2723 'type' => 'aType',
2724 'title' => 'yetAnotherTitle',
2725 ],
2726 'andYetAnotherWizard' => [
2727 'type' => 'aType',
2728 'title' => 'yetAnotherTitle',
2729 'enableByTypeConfig' => 0,
2730 ],
2731 ],
2732 ],
2733 ],
2734 ],
2735 'types' => [
2736 'firstType' => [
2737 'columnsOverrides' => [
2738 'aField' => [
2739 'defaultExtras' => 'nowrap:wizards[aWizard|anotherWizard|aNotExistingWizard]:enable-tab',
2740 ],
2741 ],
2742 ],
2743 'secondType' => [
2744 'columnsOverrides' => [
2745 'aField' => [
2746 'defaultExtras' => 'wizards[aWizard]',
2747 ],
2748 ],
2749 ],
2750 ],
2751 ],
2752 ],
2753 [
2754 'aTable' => [
2755 'columns' => [
2756 'aField' => [
2757 'exclude' => true,
2758 'label' => 'aLabel',
2759 'config' => [
2760 'type' => 'text',
2761 'wizards' => [
2762 'yetAnotherWizard' => [
2763 'type' => 'aType',
2764 'title' => 'yetAnotherTitle',
2765 ],
2766 'andYetAnotherWizard' => [
2767 'type' => 'aType',
2768 'title' => 'yetAnotherTitle',
2769 ],
2770 ],
2771 ],
2772 ],
2773 ],
2774 'types' => [
2775 'firstType' => [
2776 'columnsOverrides' => [
2777 'aField' => [
2778 'config' => [
2779 'wrap' => 'off',
2780 'enableTabulator' => true,
2781 'wizards' => [
2782 'aWizard' => [
2783 'type' => 'aType',
2784 'title' => 'aTitle',
2785 ],
2786 'anotherWizard' => [
2787 'type' => 'aType',
2788 'title' => 'anotherTitle',
2789 ],
2790 ],
2791 ],
2792 ],
2793 ],
2794 ],
2795 'secondType' => [
2796 'columnsOverrides' => [
2797 'aField' => [
2798 'config' => [
2799 'wizards' => [
2800 'aWizard' => [
2801 'type' => 'aType',
2802 'title' => 'aTitle',
2803 ],
2804 ],
2805 ],
2806 ],
2807 ],
2808 ],
2809 ],
2810 ],
2811 ],
2812 ],
2813 'empty wizard array is removed' => [
2814 [
2815 'aTable' => [
2816 'columns' => [
2817 'aField' => [
2818 'exclude' => true,
2819 'label' => 'aLabel',
2820 'config' => [
2821 'type' => 'input',
2822 'wizards' => [
2823 'aWizard' => [
2824 'type' => 'aType',
2825 'title' => 'aTitle',
2826 'enableByTypeConfig' => 1,
2827 ],
2828 ],
2829 ],
2830 ],
2831 ],
2832 'types' => [
2833 'firstType' => [
2834 'columnsOverrides' => [
2835 'aField' => [
2836 'defaultExtras' => 'wizards[aWizard]',
2837 ],
2838 ],
2839 ],
2840 ],
2841 ],
2842 ],
2843 [
2844 'aTable' => [
2845 'columns' => [
2846 'aField' => [
2847 'exclude' => true,
2848 'label' => 'aLabel',
2849 'config' => [
2850 'type' => 'input',
2851 ],
2852 ],
2853 ],
2854 'types' => [
2855 'firstType' => [
2856 'columnsOverrides' => [
2857 'aField' => [
2858 'config' => [
2859 'wizards' => [
2860 'aWizard' => [
2861 'type' => 'aType',
2862 'title' => 'aTitle',
2863 ],
2864 ],
2865 ],
2866 ],
2867 ],
2868 ],
2869 ],
2870 ],
2871 ],
2872 ],
2873 ];
2874 }
2875
2876 /**
2877 * @param array $input
2878 * @param array $expected
2879 * @test
2880 * @dataProvider migrateMovesWizardsWithEnableByTypeConfigToColumnsOverridesDataProvider
2881 */
2882 public function migrateMovesWizardsWithEnableByTypeConfigToColumnsOverrides(array $input, array $expected): void
2883 {
2884 $this->assertEquals($expected, (new TcaMigration())->migrate($input));
2885 }
2886
2887 /**
2888 * @return array
2889 */
2890 public function migrateRewritesColorpickerWizardDataProvider(): array
2891 {
2892 return [
2893 'colorpicker in columns field' => [
2894 [
2895 'aTable' => [
2896 'columns' => [
2897 'aCol' => [
2898 'config' => [
2899 'type' => 'input',
2900 'wizards' => [
2901 'colorpicker' => [
2902 'type' => 'colorbox',
2903 'title' => 'Color picker',
2904 'module' => [
2905 'name' => 'wizard_colorpicker',
2906 ],
2907 'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1',
2908 ],
2909 ],
2910 ],
2911 ],
2912 ],
2913 ],
2914 ],
2915 [
2916 'aTable' => [
2917 'columns' => [
2918 'aCol' => [
2919 'config' => [
2920 'type' => 'input',
2921 'renderType' => 'colorpicker',
2922 ],
2923 ],
2924 ],
2925 ],
2926 ],
2927 ],
2928 'colorpicker is not migrated if custom renderType is already given' => [
2929 [
2930 'aTable' => [
2931 'columns' => [
2932 'aCol' => [
2933 'config' => [
2934 'type' => 'input',
2935 'renderType' => 'myPersonalRenderType',
2936 'wizards' => [
2937 'colorpicker' => [
2938 'type' => 'colorbox',
2939 'title' => 'Color picker',
2940 'module' => [
2941 'name' => 'wizard_colorpicker',
2942 ],
2943 'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1',
2944 ],
2945 ],
2946 ],
2947 ],
2948 ],
2949 ],
2950 ],
2951 [
2952 'aTable' => [
2953 'columns' => [
2954 'aCol' => [
2955 'config' => [
2956 'type' => 'input',
2957 'renderType' => 'myPersonalRenderType',
2958 'wizards' => [
2959 'colorpicker' => [
2960 'type' => 'colorbox',
2961 'title' => 'Color picker',
2962 'module' => [
2963 'name' => 'wizard_colorpicker',
2964 ],
2965 'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1',
2966 ],
2967 ],
2968 ],
2969 ],
2970 ],
2971 ],
2972 ],
2973 ],
2974 'colorpicker in a type columnsOverrides field' => [
2975 [
2976 'aTable' => [
2977 'columns' => [
2978 'aField' => [
2979 'config' => [
2980 'type' => 'input',
2981 ]
2982 ]
2983 ],
2984 'types' => [
2985 'aType' => [
2986 'columnsOverrides' => [
2987 'aField' => [
2988 'config' => [
2989 'wizards' => [
2990 'colorpicker' => [
2991 'type' => 'colorbox',
2992 'title' => 'Color picker',
2993 'module' => [
2994 'name' => 'wizard_colorpicker',
2995 ],
2996 'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1',
2997 ],
2998 ],
2999 ],
3000 ],
3001 ],
3002 ],
3003 ],
3004 ],
3005 ],
3006 [
3007 'aTable' => [
3008 'columns' => [
3009 'aField' => [
3010 'config' => [
3011 'type' => 'input',
3012 ]
3013 ]
3014 ],
3015 'types' => [
3016 'aType' => [
3017 'columnsOverrides' => [
3018 'aField' => [
3019 'config' => [
3020 'type' => 'input',
3021 'renderType' => 'colorpicker',
3022 ],
3023 ],
3024 ],
3025 ],
3026 ],
3027 ],
3028 ]
3029 ]
3030 ];
3031 }
3032
3033 /**
3034 * @param array $input
3035 * @param array $expected
3036 * @test
3037 * @dataProvider migrateRewritesColorpickerWizardDataProvider
3038 */
3039 public function migrateRewritesColorpickerWizard(array $input, array $expected): void
3040 {
3041 $this->assertEquals($expected, (new TcaMigration())->migrate($input));
3042 }
3043
3044 /**
3045 * @return array
3046 */
3047 public function migrateMovesSelectWizardToValuePickerDataProvider(): array
3048 {
3049 return [
3050 'select wizard without mode' => [
3051 [
3052 'aTable' => [
3053 'columns' => [
3054 'aField' => [
3055 'label' => 'foo',
3056 'config' => [
3057 'type' => 'text',
3058 'wizards' => [
3059 'target_picker' => [
3060 'type' => 'select',
3061 'items' => [
3062 [ 'aLabel', 'aValue' ],
3063 [ 'anotherLabel', 'anotherValue' ],
3064 ],
3065 ],
3066 ],
3067 ],
3068 ],
3069 ],
3070 ],
3071 ],
3072 [
3073 'aTable' => [
3074 'columns' => [
3075 'aField' => [
3076 'label' => 'foo',
3077 'config' => [
3078 'type' => 'text',
3079 'valuePicker' => [
3080 'items' => [
3081 [ 'aLabel', 'aValue' ],
3082 [ 'anotherLabel', 'anotherValue' ],
3083 ],
3084 ],
3085 ],
3086 ],
3087 ],
3088 ],
3089 ],
3090 ],
3091 'select wizard with empty mode' => [
3092 [
3093 'aTable' => [
3094 'columns' => [
3095 'aField' => [
3096 'label' => 'foo',
3097 'config' => [
3098 'type' => 'input',
3099 'wizards' => [
3100 'target_picker' => [
3101 'type' => 'select',
3102 'mode' => '',
3103 'items' => [
3104 [ 'aLabel', 'aValue' ],
3105 [ 'anotherLabel', 'anotherValue' ],
3106 ],
3107 ],
3108 ],
3109 ],
3110 ],
3111 ],
3112 ],
3113 ],
3114 [
3115 'aTable' => [
3116 'columns' => [
3117 'aField' => [
3118 'label' => 'foo',
3119 'config' => [
3120 'type' => 'input',
3121 'valuePicker' => [
3122 'mode' => '',
3123 'items' => [
3124 [ 'aLabel', 'aValue' ],
3125 [ 'anotherLabel', 'anotherValue' ],
3126 ],
3127 ],
3128 ],
3129 ],
3130 ],
3131 ],
3132 ],
3133 ],
3134 'select wizard with prepend mode' => [
3135 [
3136 'aTable' => [
3137 'columns' => [
3138 'aField' => [
3139 'label' => 'foo',
3140 'config' => [
3141 'type' => 'input',
3142 'wizards' => [
3143 'target_picker' => [
3144 'type' => 'select',
3145 'mode' => 'prepend',
3146 'items' => [
3147 [ 'aLabel', 'aValue' ],
3148 [ 'anotherLabel', 'anotherValue' ],
3149 ],
3150 ],
3151 ],
3152 ],
3153 ],
3154 ],
3155 ],
3156 ],
3157 [
3158 'aTable' => [
3159 'columns' => [
3160 'aField' => [
3161 'label' => 'foo',
3162 'config' => [
3163 'type' => 'input',
3164 'valuePicker' => [
3165 'mode' => 'prepend',
3166 'items' => [
3167 [ 'aLabel', 'aValue' ],
3168 [ 'anotherLabel', 'anotherValue' ],
3169 ],
3170 ],
3171 ],
3172 ],
3173 ],
3174 ],
3175 ],
3176 ],
3177 'select wizard with append mode' => [
3178 [
3179 'aTable' => [
3180 'columns' => [
3181 'aField' => [
3182 'label' => 'foo',
3183 'config' => [
3184 'type' => 'input',
3185 'wizards' => [
3186 'target_picker' => [
3187 'type' => 'select',
3188 'mode' => 'append',
3189 'items' => [
3190 [ 'aLabel', 'aValue' ],
3191 [ 'anotherLabel', 'anotherValue' ],
3192 ],
3193 ],
3194 ],
3195 ],
3196 ],
3197 ],
3198 ],
3199 ],
3200 [
3201 'aTable' => [
3202 'columns' => [
3203 'aField' => [
3204 'label' => 'foo',
3205 'config' => [
3206 'type' => 'input',
3207 'valuePicker' => [
3208 'mode' => 'append',
3209 'items' => [
3210 [ 'aLabel', 'aValue' ],
3211 [ 'anotherLabel', 'anotherValue' ],
3212 ],
3213 ],
3214 ],
3215 ],
3216 ],
3217 ],
3218 ],
3219 ],
3220 'select wizard with broken mode' => [
3221 [
3222 'aTable' => [
3223 'columns' => [
3224 'aField' => [
3225 'label' => 'foo',
3226 'config' => [
3227 'type' => 'input',
3228 'wizards' => [
3229 'target_picker' => [
3230 'type' => 'select',
3231 'mode' => 'foo',
3232 'items' => [
3233 [ 'aLabel', 'aValue' ],
3234 [ 'anotherLabel', 'anotherValue' ],
3235 ],
3236 ],
3237 ],
3238 ],
3239 ],
3240 ],
3241 ],
3242 ],
3243 [
3244 'aTable' => [
3245 'columns' => [
3246 'aField' => [
3247 'label' => 'foo',
3248 'config' => [
3249 'type' => 'input',
3250 'valuePicker' => [
3251 'items' => [
3252 [ 'aLabel', 'aValue' ],
3253 [ 'anotherLabel', 'anotherValue' ],
3254 ],
3255 ],
3256 ],
3257 ],
3258 ],
3259 ],
3260 ],
3261 ],
3262 'select wizard without items is not migrated' => [
3263 [
3264 'aTable' => [
3265 'columns' => [
3266 'aField' => [
3267 'label' => 'foo',
3268 'config' => [
3269 'type' => 'input',
3270 'wizards' => [
3271 'target_picker' => [
3272 'type' => 'select',
3273 'mode' => '',
3274 ],
3275 ],
3276 ],
3277 ],
3278 ],
3279 ],
3280 ],
3281 [
3282 'aTable' => [
3283 'columns' => [
3284 'aField' => [
3285 'label' => 'foo',
3286 'config' => [
3287 'type' => 'input',
3288 'wizards' => [
3289 'target_picker' => [
3290 'type' => 'select',
3291 'mode' => '',
3292 ],
3293 ],
3294 ],
3295 ],
3296 ],
3297 ],
3298 ],
3299 ],
3300 'select wizard with broken items is not migrated' => [
3301 [
3302 'aTable' => [
3303 'columns' => [
3304 'aField' => [
3305 'label' => 'foo',
3306 'config' => [
3307 'type' => 'input',
3308 'wizards' => [
3309 'target_picker' => [
3310 'type' => 'select',
3311 'mode' => '',
3312 'items' => 'foo',
3313 ],
3314 ],
3315 ],
3316 ],
3317 ],
3318 ],
3319 ],
3320 [
3321 'aTable' => [
3322 'columns' => [
3323 'aField' => [
3324 'label' => 'foo',
3325 'config' => [
3326 'type' => 'input',
3327 'wizards' => [
3328 'target_picker' => [
3329 'type' => 'select',
3330 'mode' => '',
3331 'items' => 'foo',
3332 ],
3333 ],
3334 ],
3335 ],
3336 ],
3337 ],
3338 ],
3339 ],
3340 'two wizards' => [
3341 [
3342 'aTable' => [
3343 'columns' => [
3344 'aField' => [
3345 'label' => 'foo',
3346 'config' => [
3347 'type' => 'input',
3348 'wizards' => [
3349 'target_picker' => [
3350 'type' => 'select',
3351 'mode' => '',
3352 'items' => [
3353 [ 'aLabel', 'aValue' ],
3354 [ 'anotherLabel', 'anotherValue' ],
3355 ],
3356 ],
3357 'differentWizard' => [
3358 'type' => 'foo',
3359 ]
3360 ],
3361 ],
3362 ],
3363 ],
3364 ],
3365 ],
3366 [
3367 'aTable' => [
3368 'columns' => [
3369 'aField' => [
3370 'label' => 'foo',
3371 'config' => [
3372 'type' => 'input',
3373 'valuePicker' => [
3374 'mode' => '',
3375 'items' => [
3376 [ 'aLabel', 'aValue' ],
3377 [ 'anotherLabel', 'anotherValue' ],
3378 ],
3379 ],
3380 'wizards' => [
3381 'differentWizard' => [
3382 'type' => 'foo',
3383 ],
3384 ]
3385 ],
3386 ],
3387 ],
3388 ],
3389 ],
3390 ],
3391 'select value wizard to value Picker columnsOverrides field' => [
3392 [
3393 'aTable' => [
3394 'columns' => [
3395 'aField' => [
3396 'config' => [
3397 'type' => 'text',
3398 ]
3399 ]
3400 ],
3401 'types' => [
3402 'aType' => [
3403 'columnsOverrides' => [
3404 'aField' => [
3405 'config' => [
3406 'wizards' => [
3407 'target_picker' => [
3408 'type' => 'select',
3409 'items' => [
3410 [ 'aLabel', 'aValue' ],
3411 [ 'anotherLabel', 'anotherValue' ],
3412 ],
3413 ],
3414 ],
3415 ],
3416 ],
3417 ],
3418 ],
3419 ],
3420 ],
3421 ],
3422 [
3423 'aTable' => [
3424 'columns' => [
3425 'aField' => [
3426 'config' => [
3427 'type' => 'text',
3428 ]
3429 ]
3430 ],
3431 'types' => [
3432 'aType' => [
3433 'columnsOverrides' => [
3434 'aField' => [
3435 'config' => [
3436 'valuePicker' => [
3437 'items' => [
3438 [ 'aLabel', 'aValue' ],
3439 [ 'anotherLabel', 'anotherValue' ],
3440 ],
3441 ],
3442 ],
3443 ],
3444 ],
3445 ],
3446 ],
3447 ],
3448 ]
3449 ]
3450 ];
3451 }
3452
3453 /**
3454 * @param array $input
3455 * @param array $expected
3456 * @test
3457 * @dataProvider migrateMovesSelectWizardToValuePickerDataProvider
3458 */
3459 public function migrateMovesSelectWizardToValuePicker(array $input, array $expected): void
3460 {
3461 $this->assertEquals($expected, (new TcaMigration())->migrate($input));
3462 }
3463
3464 /**
3465 * @return array
3466 */
3467 public function migrateMovesSliderWizardToSliderConfigurationDataProvider(): array
3468 {
3469 return [
3470 'slider wizard with no options' => [
3471 [
3472 'aTable' => [
3473 'columns' => [
3474 'aField' => [
3475 'label' => 'foo',
3476 'config' => [
3477 'type' => 'input',
3478 'wizards' => [
3479 'slider' => [
3480