[TASK] Unit tests to addPlugin() 35/31335/2
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 5 Jul 2014 11:51:35 +0000 (13:51 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 5 Jul 2014 12:08:46 +0000 (14:08 +0200)
Add unit tests to ExtensionManagementUtility::addPlugin() verifying
the new third parameter $extensionKey is handled properly.

Change-Id: I0257755d0708f12141c78fb97e6e342daf7a6281
Resolves: #60110
Related: #60109
Related: #59414
Related: #59770
Related: #59468
Releases: 6.2, 6.3
Reviewed-on: https://review.typo3.org/31335
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php

index 52efb19..5712da8 100644 (file)
@@ -1351,4 +1351,54 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                ExtensionManagementUtility::makeCategorizable($extensionKey, $tableName, $fieldName);
        }
 
+       ///////////////////////////////
+       // Tests concerning addPlugin
+       ///////////////////////////////
+
+       /**
+        * @test
+        */
+       public function addPluginSetsTcaCorrectlyForGivenExtkeyAsParameter() {
+               $extKey = 'indexed_search';
+               $GLOBALS['TYPO3_LOADED_EXT'] = array();
+               $GLOBALS['TYPO3_LOADED_EXT'][$extKey]['ext_icon'] = 'foo.gif';
+               $expectedTCA = array(
+                       array(
+                               'label',
+                               $extKey,
+                               'sysext/' . $extKey . '/foo.gif'
+                       )
+               );
+               $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] = array();
+               ExtensionManagementUtility::addPlugin(array('label', $extKey), 'list_type', $extKey);
+               $this->assertEquals($expectedTCA, $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items']);
+       }
+
+       /**
+        * @test
+        */
+       public function addPluginSetsTcaCorrectlyForGivenExtkeyAsGlobal() {
+               $extKey = 'indexed_search';
+               $GLOBALS['TYPO3_LOADED_EXT'] = array();
+               $GLOBALS['TYPO3_LOADED_EXT'][$extKey]['ext_icon'] = 'foo.gif';
+               $GLOBALS['_EXTKEY'] = $extKey;
+               $expectedTCA = array(
+                       array(
+                               'label',
+                               $extKey,
+                               'sysext/' . $extKey . '/foo.gif'
+                       )
+               );
+               $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] = array();
+               ExtensionManagementUtility::addPlugin(array('label', $extKey));
+               $this->assertEquals($expectedTCA, $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items']);
+       }
+
+       /**
+        * @test
+        * @expectedException \RuntimeException
+        */
+       public function addPluginThrowsExceptionForMissingExtkey() {
+               ExtensionManagementUtility::addPlugin('test');
+       }
 }