[TASK] Deprecate inline localizationMode
[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 migratePageLocalizationDefinitionsDataProvider()
2153 {
2154 return [
2155 'missing l10n_mode' => [
2156 [
2157 'pages' => [
2158 'columns' => [
2159 'aColumn' => [
2160 'config' => [
2161 'type' => 'input',
2162 ],
2163 'l10n_mode' => 'any-possible-value',
2164 ],
2165 ],
2166 ],
2167 'pages_language_overlay' => [
2168 'columns' => [
2169 'aColumn' => [
2170 'config' => [
2171 'type' => 'input',
2172 ],
2173 ],
2174 ],
2175 ],
2176 ],
2177 [
2178 'pages' => [
2179 'columns' => [
2180 'aColumn' => [
2181 'config' => [
2182 'type' => 'input',
2183 ],
2184 ],
2185 ],
2186 ],
2187 'pages_language_overlay' => [
2188 'columns' => [
2189 'aColumn' => [
2190 'config' => [
2191 'type' => 'input',
2192 ],
2193 'l10n_mode' => 'any-possible-value',
2194 ],
2195 ],
2196 ],
2197 ]
2198 ],
2199 'missing allowLanguageSynchronization' => [
2200 [
2201 'pages' => [
2202 'columns' => [
2203 'aColumn' => [
2204 'config' => [
2205 'type' => 'input',
2206 'behaviour' => [
2207 'allowLanguageSynchronization' => true,
2208 ]
2209 ],
2210 ],
2211 ],
2212 ],
2213 'pages_language_overlay' => [
2214 'columns' => [
2215 'aColumn' => [
2216 'config' => [
2217 'type' => 'input',
2218 ],
2219 ],
2220 ],
2221 ],
2222 ],
2223 [
2224 'pages' => [
2225 'columns' => [
2226 'aColumn' => [
2227 'config' => [
2228 'type' => 'input',
2229 'behaviour' => []
2230 ],
2231 ],
2232 ],
2233 ],
2234 'pages_language_overlay' => [
2235 'columns' => [
2236 'aColumn' => [
2237 'config' => [
2238 'type' => 'input',
2239 'behaviour' => [
2240 'allowLanguageSynchronization' => true,
2241 ]
2242 ],
2243 ],
2244 ],
2245 ],
2246 ]
2247 ],
2248 'superfluous l10n_mode' => [
2249 [
2250 'pages' => [
2251 'columns' => [
2252 'aColumn' => [],
2253 ],
2254 ],
2255 'pages_language_overlay' => [
2256 'columns' => [
2257 'aColumn' => [
2258 'config' => [
2259 'type' => 'input',
2260 ],
2261 'l10n_mode' => 'any-possible-value',
2262 ],
2263 ],
2264 ],
2265 ],
2266 [
2267 'pages' => [
2268 'columns' => [
2269 'aColumn' => [],
2270 ],
2271 ],
2272 'pages_language_overlay' => [
2273 'columns' => [
2274 'aColumn' => [
2275 'config' => [
2276 'type' => 'input',
2277 ],
2278 ],
2279 ],
2280 ],
2281 ]
2282 ],
2283 'superfluous allowLanguageSynchronization' => [
2284 [
2285 'pages' => [
2286 'columns' => [
2287 'aColumn' => [],
2288 ],
2289 ],
2290 'pages_language_overlay' => [
2291 'columns' => [
2292 'aColumn' => [
2293 'config' => [
2294 'type' => 'input',
2295 'behaviour' => [
2296 'allowLanguageSynchronization' => true,
2297 ]
2298 ],
2299 ],
2300 ],
2301 ],
2302 ],
2303 [
2304 'pages' => [
2305 'columns' => [
2306 'aColumn' => [],
2307 ],
2308 ],
2309 'pages_language_overlay' => [
2310 'columns' => [
2311 'aColumn' => [
2312 'config' => [
2313 'type' => 'input',
2314 'behaviour' => []
2315 ],
2316 ],
2317 ],
2318 ],
2319 ]
2320 ],
2321 ];
2322 }
2323
2324 /**
2325 * @param array $givenConfig
2326 * @param array $expectedConfig
2327 * @test
2328 * @dataProvider migratePageLocalizationDefinitionsDataProvider
2329 */
2330 public function migratePageLocalizationDefinitions(array $givenConfig, array $expectedConfig)
2331 {
2332 $subject = new TcaMigration();
2333 $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
2334 }
2335
2336 /**
2337 * @return array
2338 */
2339 public function migrateInlineLocalizationModeDataProvider()
2340 {
2341 return [
2342 'remove counter-productive localizationMode=keep' => [
2343 [
2344 'aTable' => [
2345 'columns' => [
2346 'aColumn' => [
2347 'config' => [
2348 'type' => 'inline',
2349 'behaviour' => [
2350 'localizationMode' => 'keep',
2351 'allowLanguageSynchronization' => true,
2352 ],
2353 ]
2354 ],
2355 ],
2356 ],
2357 ],
2358 [
2359 'aTable' => [
2360 'columns' => [
2361 'aColumn' => [
2362 'config' => [
2363 'type' => 'inline',
2364 'behaviour' => [
2365 'allowLanguageSynchronization' => true,
2366 ],
2367 ],
2368 ],
2369 ],
2370 ],
2371 ]
2372 ],
2373 'keep deprecated localizationMode=keep' => [
2374 [
2375 'aTable' => [
2376 'columns' => [
2377 'aColumn' => [
2378 'config' => [
2379 'type' => 'inline',
2380 'behaviour' => [
2381 'localizationMode' => 'keep',
2382 ],
2383 ],
2384 ],
2385 ],
2386 ],
2387 ],
2388 [
2389 'aTable' => [
2390 'columns' => [
2391 'aColumn' => [
2392 'config' => [
2393 'type' => 'inline',
2394 'behaviour' => [
2395 'localizationMode' => 'keep',
2396 ],
2397 ]
2398 ],
2399 ],
2400 ],
2401 ]
2402 ],
2403 'keep deprecated localizationMode=select' => [
2404 [
2405 'aTable' => [
2406 'columns' => [
2407 'aColumn' => [
2408 'config' => [
2409 'type' => 'inline',
2410 'behaviour' => [
2411 'localizationMode' => 'select',
2412 ],
2413 ],
2414 ],
2415 ],
2416 ],
2417 ],
2418 [
2419 'aTable' => [
2420 'columns' => [
2421 'aColumn' => [
2422 'config' => [
2423 'type' => 'inline',
2424 'behaviour' => [
2425 'localizationMode' => 'select',
2426 ],
2427 ]
2428 ],
2429 ],
2430 ],
2431 ]
2432 ],
2433 ];
2434 }
2435
2436 /**
2437 * @param array $givenConfig
2438 * @param array $expectedConfig
2439 * @test
2440 * @dataProvider migrateInlineLocalizationModeDataProvider
2441 */
2442 public function migrateInlineLocalizationMode(array $givenConfig, array $expectedConfig)
2443 {
2444 $subject = new TcaMigration();
2445 $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
2446 $this->assertNotEmpty($subject->getMessages());
2447 }
2448
2449 /**
2450 * @return array
2451 */
2452 public function migrateMovesRequestUpdateCtrlFieldToColumnsDataProvider()
2453 {
2454 return [
2455 'move single field name' => [
2456 [
2457 'aTable' => [
2458 'ctrl' => [
2459 'requestUpdate' => 'aField',
2460 ],
2461 'columns' => [
2462 'aField' => [
2463 'label' => 'foo',
2464 'config' => [
2465 'type' => 'input',
2466 ],
2467 ],
2468 ],
2469 ],
2470 ],
2471 [
2472 'aTable' => [
2473 'ctrl' => [],
2474 'columns' => [
2475 'aField' => [
2476 'label' => 'foo',
2477 'config' => [
2478 'type' => 'input',
2479 ],
2480 'onChange' => 'reload',
2481 ],
2482 ],
2483 ],
2484 ],
2485 ],
2486 'ignore missing field but migrate others' => [
2487 [
2488 'aTable' => [
2489 'ctrl' => [
2490 'requestUpdate' => 'aField, bField, cField, ',
2491 ],
2492 'columns' => [
2493 'aField' => [],
2494 'cField' => [],
2495 ],
2496 ],
2497 ],
2498 [
2499 'aTable' => [
2500 'ctrl' => [],
2501 'columns' => [
2502 'aField' => [
2503 'onChange' => 'reload',
2504 ],
2505 'cField' => [
2506 'onChange' => 'reload',
2507 ],
2508 ],
2509 ],
2510 ],
2511 ],
2512 ];
2513 }
2514
2515 /**
2516 * @param array $input
2517 * @param array $expected
2518 * @test
2519 * @dataProvider migrateMovesRequestUpdateCtrlFieldToColumnsDataProvider
2520 */
2521 public function migrateMovesRequestUpdateCtrlFieldToColumns(array $input, array $expected)
2522 {
2523 $this->assertEquals($expected, (new TcaMigration())->migrate($input));
2524 }
2525
2526 /**
2527 * @return array
2528 */
2529 public function migrateMovesTypeInputDateTimeToRenderTypeDataProvider()
2530 {
2531 return [
2532 'simple input with eval date' => [
2533 [
2534 'aTable' => [
2535 'columns' => [
2536 'aField' => [
2537 'label' => 'foo',
2538 'config' => [
2539 'type' => 'input',
2540 'eval' => 'date',
2541 ],
2542 ],
2543 ],
2544 ],
2545 ],
2546 [
2547 'aTable' => [
2548 'columns' => [
2549 'aField' => [
2550 'label' => 'foo',
2551 'config' => [
2552 'type' => 'input',
2553 'eval' => 'date',
2554 'renderType' => 'inputDateTime',
2555 ],
2556 ],
2557 ],
2558 ],
2559 ]
2560 ],
2561 'simple input with eval datetime' => [
2562 [
2563 'aTable' => [
2564 'columns' => [
2565 'aField' => [
2566 'label' => 'foo',
2567 'config' => [
2568 'type' => 'input',
2569 'eval' => 'datetime',
2570 ],
2571 ],
2572 ],
2573 ],
2574 ],
2575 [
2576 'aTable' => [
2577 'columns' => [
2578 'aField' => [
2579 'label' => 'foo',
2580 'config' => [
2581 'type' => 'input',
2582 'eval' => 'datetime',
2583 'renderType' => 'inputDateTime',
2584 ],
2585 ],
2586 ],
2587 ],
2588 ]
2589 ],
2590 'simple input with eval time' => [
2591 [
2592 'aTable' => [
2593 'columns' => [
2594 'aField' => [
2595 'label' => 'foo',
2596 'config' => [
2597 'type' => 'input',
2598 'eval' => 'time',
2599 ],
2600 ],
2601 ],
2602 ],
2603 ],
2604 [
2605 'aTable' => [
2606 'columns' => [
2607 'aField' => [
2608 'label' => 'foo',
2609 'config' => [
2610 'type' => 'input',
2611 'eval' => 'time',
2612 'renderType' => 'inputDateTime',
2613 ],
2614 ],
2615 ],
2616 ],
2617 ]
2618 ],
2619 'simple input with eval timesec' => [
2620 [
2621 'aTable' => [
2622 'columns' => [
2623 'aField' => [
2624 'label' => 'foo',
2625 'config' => [
2626 'type' => 'input',
2627 'eval' => 'timesec',
2628 ],
2629 ],
2630 ],
2631 ],
2632 ],
2633 [
2634 'aTable' => [
2635 'columns' => [
2636 'aField' => [
2637 'label' => 'foo',
2638 'config' => [
2639 'type' => 'input',
2640 'eval' => 'timesec',
2641 'renderType' => 'inputDateTime',
2642 ],
2643 ],
2644 ],
2645 ],
2646 ]
2647 ],
2648 'input with multiple evals' => [
2649 [
2650 'aTable' => [
2651 'columns' => [
2652 'aField' => [
2653 'label' => 'foo',
2654 'config' => [
2655 'type' => 'input',
2656 'eval' => 'null,date, required',
2657 ],
2658 ],
2659 ],
2660 ],
2661 ],
2662 [
2663 'aTable' => [
2664 'columns' => [
2665 'aField' => [
2666 'label' => 'foo',
2667 'config' => [
2668 'type' => 'input',
2669 'eval' => 'null,date, required',
2670 'renderType' => 'inputDateTime',
2671 ],
2672 ],
2673 ],
2674 ],
2675 ]
2676 ],
2677 ];
2678 }
2679
2680 /**
2681 * @param array $input
2682 * @param array $expected
2683 * @test
2684 * @dataProvider migrateMovesTypeInputDateTimeToRenderTypeDataProvider
2685 */
2686 public function migrateMovesTypeInputDateTimeToRenderType(array $input, array $expected)
2687 {
2688 $this->assertEquals($expected, (new TcaMigration())->migrate($input));
2689 }
2690
2691 /**
2692 * @return array
2693 */
2694 public function migrateMovesWizardsWithEnableByTypeConfigToColumnsOverridesDataProvider()
2695 {
2696 return [
2697 'enableByTypeConfig on multiple wizards' => [
2698 [
2699 'aTable' => [
2700 'columns' => [
2701 'aField' => [
2702 'exclude' => true,
2703 'label' => 'aLabel',
2704 'config' => [
2705 'type' => 'text',
2706 'wizards' => [
2707 'aWizard' => [
2708 'type' => 'aType',
2709 'title' => 'aTitle',
2710 'enableByTypeConfig' => '1',
2711 ],
2712 'anotherWizard' => [
2713 'type' => 'aType',
2714 'title' => 'anotherTitle',
2715 'enableByTypeConfig' => 1,
2716 ],
2717 'yetAnotherWizard' => [
2718 'type' => 'aType',
2719 'title' => 'yetAnotherTitle',
2720 ],
2721 'andYetAnotherWizard' => [
2722 'type' => 'aType',
2723 'title' => 'yetAnotherTitle',
2724 'enableByTypeConfig' => 0,
2725 ],
2726 ],
2727 ],
2728 ],
2729 ],
2730 'types' => [
2731 'firstType' => [
2732 'columnsOverrides' => [
2733 'aField' => [
2734 'defaultExtras' => 'nowrap:wizards[aWizard|anotherWizard|aNotExistingWizard]:enable-tab',
2735 ],
2736 ],
2737 ],
2738 'secondType' => [
2739 'columnsOverrides' => [
2740 'aField' => [
2741 'defaultExtras' => 'wizards[aWizard]',
2742 ],
2743 ],
2744 ],
2745 ],
2746 ],
2747 ],
2748 [
2749 'aTable' => [
2750 'columns' => [
2751 'aField' => [
2752 'exclude' => true,
2753 'label' => 'aLabel',
2754 'config' => [
2755 'type' => 'text',
2756 'wizards' => [
2757 'yetAnotherWizard' => [
2758 'type' => 'aType',
2759 'title' => 'yetAnotherTitle',
2760 ],
2761 'andYetAnotherWizard' => [
2762 'type' => 'aType',
2763 'title' => 'yetAnotherTitle',
2764 ],
2765 ],
2766 ],
2767 ],
2768 ],
2769 'types' => [
2770 'firstType' => [
2771 'columnsOverrides' => [
2772 'aField' => [
2773 'config' => [
2774 'wrap' => 'off',
2775 'enableTabulator' => true,
2776 'wizards' => [
2777 'aWizard' => [
2778 'type' => 'aType',
2779 'title' => 'aTitle',
2780 ],
2781 'anotherWizard' => [
2782 'type' => 'aType',
2783 'title' => 'anotherTitle',
2784 ],
2785 ],
2786 ],
2787 ],
2788 ],
2789 ],
2790 'secondType' => [
2791 'columnsOverrides' => [
2792 'aField' => [
2793 'config' => [
2794 'wizards' => [
2795 'aWizard' => [
2796 'type' => 'aType',
2797 'title' => 'aTitle',
2798 ],
2799 ],
2800 ],
2801 ],
2802 ],
2803 ],
2804 ],
2805 ],
2806 ],
2807 ],
2808 'empty wizard array is removed' => [
2809 [
2810 'aTable' => [
2811 'columns' => [
2812 'aField' => [
2813 'exclude' => true,
2814 'label' => 'aLabel',
2815 'config' => [
2816 'type' => 'input',
2817 'wizards' => [
2818 'aWizard' => [
2819 'type' => 'aType',
2820 'title' => 'aTitle',
2821 'enableByTypeConfig' => 1,
2822 ],
2823 ],
2824 ],
2825 ],
2826 ],
2827 'types' => [
2828 'firstType' => [
2829 'columnsOverrides' => [
2830 'aField' => [
2831 'defaultExtras' => 'wizards[aWizard]',
2832 ],
2833 ],
2834 ],
2835 ],
2836 ],
2837 ],
2838 [
2839 'aTable' => [
2840 'columns' => [
2841 'aField' => [
2842 'exclude' => true,
2843 'label' => 'aLabel',
2844 'config' => [
2845 'type' => 'input',
2846 ],
2847 ],
2848 ],
2849 'types' => [
2850 'firstType' => [
2851 'columnsOverrides' => [
2852 'aField' => [
2853 'config' => [
2854 'wizards' => [
2855 'aWizard' => [
2856 'type' => 'aType',
2857 'title' => 'aTitle',
2858 ],
2859 ],
2860 ],
2861 ],
2862 ],
2863 ],
2864 ],
2865 ],
2866 ],
2867 ],
2868 ];
2869 }
2870
2871 /**
2872 * @param array $input
2873 * @param array $expected
2874 * @test
2875 * @dataProvider migrateMovesWizardsWithEnableByTypeConfigToColumnsOverridesDataProvider
2876 */
2877 public function migrateMovesWizardsWithEnableByTypeConfigToColumnsOverrides(array $input, array $expected)
2878 {
2879 $this->assertEquals($expected, (new TcaMigration())->migrate($input));
2880 }
2881
2882 /**
2883 * @return array
2884 */
2885 public function migrateRewritesColorpickerWizardDataProvider()
2886 {
2887 return [
2888 'colorpicker in columns field' => [
2889 [
2890 'aTable' => [
2891 'columns' => [
2892 'aCol' => [
2893 'config' => [
2894 'type' => 'input',
2895 'wizards' => [
2896 'colorpicker' => [
2897 'type' => 'colorbox',
2898 'title' => 'Color picker',
2899 'module' => [
2900 'name' => 'wizard_colorpicker',
2901 ],
2902 'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1',
2903 ],
2904 ],
2905 ],
2906 ],
2907 ],
2908 ],
2909 ],
2910 [
2911 'aTable' => [
2912 'columns' => [
2913 'aCol' => [
2914 'config' => [
2915 'type' => 'input',
2916 'renderType' => 'colorpicker',
2917 ],
2918 ],
2919 ],
2920 ],
2921 ],
2922 ],
2923 'colorpicker is not migrated if custom renderType is already given' => [
2924 [
2925 'aTable' => [
2926 'columns' => [
2927 'aCol' => [
2928 'config' => [
2929 'type' => 'input',
2930 'renderType' => 'myPersonalRenderType',
2931 'wizards' => [
2932 'colorpicker' => [
2933 'type' => 'colorbox',
2934 'title' => 'Color picker',
2935 'module' => [
2936 'name' => 'wizard_colorpicker',
2937 ],
2938 'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1',
2939 ],
2940 ],
2941 ],
2942 ],
2943 ],
2944 ],
2945 ],
2946 [
2947 'aTable' => [
2948 'columns' => [
2949 'aCol' => [
2950 'config' => [
2951 'type' => 'input',
2952 'renderType' => 'myPersonalRenderType',
2953 'wizards' => [
2954 'colorpicker' => [
2955 'type' => 'colorbox',
2956 'title' => 'Color picker',
2957 'module' => [
2958 'name' => 'wizard_colorpicker',
2959 ],
2960 'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1',
2961 ],
2962 ],
2963 ],
2964 ],
2965 ],
2966 ],
2967 ],
2968 ],
2969 'colorpicker in a type columnsOverrides field' => [
2970 [
2971 'aTable' => [
2972 'columns' => [
2973 'aField' => [
2974 'config' => [
2975 'type' => 'input',
2976 ]
2977 ]
2978 ],
2979 'types' => [
2980 'aType' => [
2981 'columnsOverrides' => [
2982 'aField' => [
2983 'config' => [
2984 'wizards' => [
2985 'colorpicker' => [
2986 'type' => 'colorbox',
2987 'title' => 'Color picker',
2988 'module' => [
2989 'name' => 'wizard_colorpicker',
2990 ],
2991 'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1',
2992 ],
2993 ],
2994 ],
2995 ],
2996 ],
2997 ],
2998 ],
2999 ],
3000 ],
3001 [
3002 'aTable' => [
3003 'columns' => [
3004 'aField' => [
3005 'config' => [
3006 'type' => 'input',
3007 ]
3008 ]
3009 ],
3010 'types' => [
3011 'aType' => [
3012 'columnsOverrides' => [
3013 'aField' => [
3014 'config' => [
3015 'type' => 'input',
3016 'renderType' => 'colorpicker',
3017 ],
3018 ],
3019 ],
3020 ],
3021 ],
3022 ],
3023 ]
3024 ]
3025 ];
3026 }
3027
3028 /**
3029 * @param array $input
3030 * @param array $expected
3031 * @test
3032 * @dataProvider migrateRewritesColorpickerWizardDataProvider
3033 */
3034 public function migrateRewritesColorpickerWizard(array $input, array $expected)
3035 {
3036 $this->assertEquals($expected, (new TcaMigration())->migrate($input));
3037 }
3038
3039 /**
3040 * @return array
3041 */
3042 public function migrateMovesSelectWizardToValuePickerDataProvider()
3043 {
3044 return [
3045 'select wizard without mode' => [
3046 [
3047 'aTable' => [
3048 'columns' => [
3049 'aField' => [
3050 'label' => 'foo',
3051 'config' => [
3052 'type' => 'text',
3053 'wizards' => [
3054 'target_picker' => [
3055 'type' => 'select',
3056 'items' => [
3057 [ 'aLabel', 'aValue' ],
3058 [ 'anotherLabel', 'anotherValue' ],
3059 ],
3060 ],
3061 ],
3062 ],
3063 ],
3064 ],
3065 ],
3066 ],
3067 [
3068 'aTable' => [
3069 'columns' => [
3070 'aField' => [
3071 'label' => 'foo',
3072 'config' => [
3073 'type' => 'text',
3074 'valuePicker' => [
3075 'items' => [
3076 [ 'aLabel', 'aValue' ],
3077 [ 'anotherLabel', 'anotherValue' ],
3078 ],
3079 ],
3080 ],
3081 ],
3082 ],
3083 ],
3084 ],
3085 ],
3086 'select wizard with empty mode' => [
3087 [
3088 'aTable' => [
3089 'columns' => [
3090 'aField' => [
3091 'label' => 'foo',
3092 'config' => [
3093 'type' => 'input',
3094 'wizards' => [
3095 'target_picker' => [
3096 'type' => 'select',
3097 'mode' => '',
3098 'items' => [
3099 [ 'aLabel', 'aValue' ],
3100 [ 'anotherLabel', 'anotherValue' ],
3101 ],
3102 ],
3103 ],
3104 ],
3105 ],
3106 ],
3107 ],
3108 ],
3109 [
3110 'aTable' => [
3111 'columns' => [
3112 'aField' => [
3113 'label' => 'foo',
3114 'config' => [
3115 'type' => 'input',
3116 'valuePicker' => [
3117 'mode' => '',
3118 'items' => [
3119 [ 'aLabel', 'aValue' ],
3120 [ 'anotherLabel', 'anotherValue' ],
3121 ],
3122 ],
3123 ],
3124 ],
3125 ],
3126 ],
3127 ],
3128 ],
3129 'select wizard with prepend mode' => [
3130 [
3131 'aTable' => [
3132 'columns' => [
3133 'aField' => [
3134 'label' => 'foo',
3135 'config' => [
3136 'type' => 'input',
3137 'wizards' => [
3138 'target_picker' => [
3139 'type' => 'select',
3140 'mode' => 'prepend',
3141 'items' => [
3142 [ 'aLabel', 'aValue' ],
3143 [ 'anotherLabel', 'anotherValue' ],
3144 ],
3145 ],
3146 ],
3147 ],
3148 ],
3149 ],
3150 ],
3151 ],
3152 [
3153 'aTable' => [
3154 'columns' => [
3155 'aField' => [
3156 'label' => 'foo',
3157 'config' => [
3158 'type' => 'input',
3159 'valuePicker' => [
3160 'mode' => 'prepend',
3161 'items' => [
3162 [ 'aLabel', 'aValue' ],
3163 [ 'anotherLabel', 'anotherValue' ],
3164 ],
3165 ],
3166 ],
3167 ],
3168 ],
3169 ],
3170 ],
3171 ],
3172 'select wizard with append mode' => [
3173 [
3174 'aTable' => [
3175 'columns' => [
3176 'aField' => [
3177 'label' => 'foo',
3178 'config' => [
3179 'type' => 'input',
3180 'wizards' => [
3181 'target_picker' => [
3182 'type' => 'select',
3183 'mode' => 'append',
3184 'items' => [
3185 [ 'aLabel', 'aValue' ],
3186 [ 'anotherLabel', 'anotherValue' ],
3187 ],
3188 ],
3189 ],
3190 ],
3191 ],
3192 ],
3193 ],
3194 ],
3195 [
3196 'aTable' => [
3197 'columns' => [
3198 'aField' => [
3199 'label' => 'foo',
3200 'config' => [
3201 'type' => 'input',
3202 'valuePicker' => [
3203 'mode' => 'append',
3204 'items' => [
3205 [ 'aLabel', 'aValue' ],
3206 [ 'anotherLabel', 'anotherValue' ],
3207 ],
3208 ],
3209 ],
3210 ],
3211 ],
3212 ],
3213 ],
3214 ],
3215 'select wizard with broken mode' => [
3216 [
3217 'aTable' => [
3218 'columns' => [
3219 'aField' => [
3220 'label' => 'foo',
3221 'config' => [
3222 'type' => 'input',
3223 'wizards' => [
3224 'target_picker' => [
3225 'type' => 'select',
3226 'mode' => 'foo',
3227 'items' => [
3228 [ 'aLabel', 'aValue' ],
3229 [ 'anotherLabel', 'anotherValue' ],
3230 ],
3231 ],
3232 ],
3233 ],
3234 ],
3235 ],
3236 ],
3237 ],
3238 [
3239 'aTable' => [
3240 'columns' => [
3241 'aField' => [
3242 'label' => 'foo',
3243 'config' => [
3244 'type' => 'input',
3245 'valuePicker' => [
3246 'items' => [
3247 [ 'aLabel', 'aValue' ],
3248 [ 'anotherLabel', 'anotherValue' ],
3249 ],
3250 ],
3251 ],
3252 ],
3253 ],
3254 ],
3255 ],
3256 ],
3257 'select wizard without items is not migrated' => [
3258 [
3259 'aTable' => [
3260 'columns' => [
3261 'aField' => [
3262 'label' => 'foo',
3263 'config' => [
3264 'type' => 'input',
3265 'wizards' => [
3266 'target_picker' => [
3267 'type' => 'select',
3268 'mode' => '',
3269 ],
3270 ],
3271 ],
3272 ],
3273 ],
3274 ],
3275 ],
3276 [
3277 'aTable' => [
3278 'columns' => [
3279 'aField' => [
3280 'label' => 'foo',
3281 'config' => [
3282 'type' => 'input',
3283 'wizards' => [
3284 'target_picker' => [
3285 'type' => 'select',
3286 'mode' => '',
3287 ],
3288 ],
3289 ],
3290 ],
3291 ],
3292 ],
3293 ],
3294 ],
3295 'select wizard with broken items is not migrated' => [
3296 [
3297 'aTable' => [
3298 'columns' => [
3299 'aField' => [
3300 'label' => 'foo',
3301 'config' => [
3302 'type' => 'input',
3303 'wizards' => [
3304 'target_picker' => [
3305 'type' => 'select',
3306 'mode' => '',
3307 'items' => 'foo',
3308 ],
3309 ],
3310 ],
3311 ],
3312 ],
3313 ],
3314 ],
3315 [
3316 'aTable' => [
3317 'columns' => [
3318 'aField' => [
3319 'label' => 'foo',
3320 'config' => [
3321 'type' => 'input',
3322 'wizards' => [
3323 'target_picker' => [
3324 'type' => 'select',
3325 'mode' => '',
3326 'items' => 'foo',
3327 ],
3328 ],
3329 ],
3330 ],
3331 ],
3332 ],
3333 ],
3334 ],
3335 'two wizards' => [
3336 [
3337 'aTable' => [
3338 'columns' => [
3339 'aField' => [
3340 'label' => 'foo',
3341 'config' => [
3342 'type' => 'input',
3343 'wizards' => [
3344 'target_picker' => [
3345 'type' => 'select',
3346 'mode' => '',
3347 'items' => [
3348 [ 'aLabel', 'aValue' ],
3349 [ 'anotherLabel', 'anotherValue' ],
3350 ],
3351 ],
3352 'differentWizard' => [
3353 'type' => 'foo',
3354 ]
3355 ],
3356 ],
3357 ],
3358 ],
3359 ],
3360 ],
3361 [
3362 'aTable' => [
3363 'columns' => [
3364 'aField' => [
3365 'label' => 'foo',
3366 'config' => [
3367 'type' => 'input',
3368 'valuePicker' => [
3369 'mode' => '',
3370 'items' => [
3371 [ 'aLabel', 'aValue' ],
3372 [ 'anotherLabel', 'anotherValue' ],
3373 ],
3374 ],
3375 'wizards' => [
3376 'differentWizard' => [
3377 'type' => 'foo',
3378 ],
3379 ]
3380 ],
3381 ],
3382 ],
3383 ],
3384 ],
3385 ],
3386 'select value wizard to value Picker columnsOverrides field' => [
3387 [
3388 'aTable' => [
3389 'columns' => [
3390 'aField' => [
3391 'config' => [
3392 'type' => 'text',
3393 ]
3394 ]
3395 ],
3396 'types' => [
3397 'aType' => [
3398 'columnsOverrides' => [
3399 'aField' => [
3400 'config' => [
3401 'wizards' => [
3402 'target_picker' => [
3403 'type' => 'select',
3404 'items' => [
3405 [ 'aLabel', 'aValue' ],
3406 [ 'anotherLabel', 'anotherValue' ],
3407 ],
3408 ],
3409 ],
3410 ],
3411 ],
3412 ],
3413 ],
3414 ],
3415 ],
3416 ],
3417 [
3418 'aTable' => [
3419 'columns' => [
3420 'aField' => [
3421 'config' => [
3422 'type' => 'text',
3423 ]
3424 ]
3425 ],
3426 'types' => [
3427 'aType' => [
3428 'columnsOverrides' => [
3429 'aField' => [
3430 'config' => [
3431 'valuePicker' => [
3432 'items' => [
3433 [ 'aLabel', 'aValue' ],
3434 [ 'anotherLabel', 'anotherValue' ],
3435 ],
3436 ],
3437 ],
3438 ],
3439 ],
3440 ],
3441 ],
3442 ],
3443 ]
3444 ]
3445 ];
3446 }
3447
3448 /**
3449 * @param array $input
3450 * @param array $expected
3451 * @test
3452 * @dataProvider migrateMovesSelectWizardToValuePickerDataProvider
3453 */
3454 public function migrateMovesSelectWizardToValuePicker(array $input, array $expected)
3455 {
3456 $this->assertEquals($expected, (new TcaMigration())->migrate($input));
3457 }
3458
3459 /**
3460 * @return array
3461 */
3462 public function migrateMovesSliderWizardToSliderConfigurationDataProvider()
3463 {
3464 return [
3465 'slider wizard with no options' => [
3466 [
3467 'aTable' => [
3468 'columns' => [
3469 'aField' => [
3470 'label' => 'foo',
3471 'config' => [
3472 'type' => 'input',
3473 'wizards' => [
3474 'slider' => [
3475 'type' => 'slider',
3476 ],
3477 ],
3478 ],
3479 ],
3480 ],
3481 ],
3482 ],
3483 [
3484 'aTable' => [
3485 'columns' => [