[TASK] Add unit test for colorpicker TCA migration 31/47731/2
authorWouter Wolters <typo3@wouterwolters.nl>
Sat, 16 Apr 2016 18:10:44 +0000 (20:10 +0200)
committerBenni Mack <benni@typo3.org>
Sun, 17 Apr 2016 19:07:24 +0000 (21:07 +0200)
Also fixes the case when wizards array becomes empty.
We can than safely unset the complete wizards key.

Resolves: #75716
Releases: master
Change-Id: I8b0cc65823b2ec6bf8598b21be2dae3bb174e58b
Reviewed-on: https://review.typo3.org/47731
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/Migrations/TcaMigration.php
typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php

index 87528e1..038a435 100644 (file)
@@ -730,6 +730,9 @@ class TcaMigration
                         foreach ($fieldConfig['config']['wizards'] as $wizardName => $wizard) {
                             if (isset($wizard['type']) && ($wizard['type'] === 'colorbox')) {
                                 unset($fieldConfig['config']['wizards'][$wizardName]);
+                                if (empty($fieldConfig['config']['wizards'])) {
+                                    unset($fieldConfig['config']['wizards']);
+                                }
                                 $fieldConfig['config']['renderType'] = 'colorpicker';
 
                                 $this->messages[] = 'The color-picker wizard using \'colorbox\' is deprecated'
index 426accd..256659c 100644 (file)
@@ -1385,4 +1385,45 @@ class TcaMigrationTest extends UnitTestCase
         $subject = new TcaMigration();
         $this->assertEquals($expectedConfig, $subject->migrate($givenConfig));
     }
+
+    /**
+     * @test
+     */
+    public function migrateRewritesColorpickerWizard()
+    {
+        $input = [
+            'aTable' => [
+                'columns' => [
+                    'aCol' => [
+                        'config' => [
+                            'wizards' => [
+                                'colorpicker' => [
+                                    'type' => 'colorbox',
+                                    'title' => 'Color picker',
+                                    'module' => [
+                                        'name' => 'wizard_colorpicker',
+                                    ],
+                                    'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1',
+                                ],
+                            ],
+                        ],
+                    ],
+                ],
+            ],
+        ];
+        $expected = [
+            'aTable' => [
+                'columns' => [
+                    'aCol' => [
+                        'config' => [
+                            'renderType' => 'colorpicker',
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $subject = new TcaMigration();
+        $this->assertEquals($expected, $subject->migrate($input));
+    }
 }