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