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