[CLEANUP] Cleanup ExtensionManagementUtility
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Utility / ExtensionManagementUtilityTest.php
index 76bb529..46a2f13 100644 (file)
@@ -296,6 +296,42 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                return $tca;
        }
 
+       /**
+        * Data provider for getClassNamePrefixForExtensionKey.
+        *
+        * @return array
+        */
+       public function extensionKeyDataProvider() {
+               return array(
+                       'Without underscores' => array(
+                               'testkey',
+                               'tx_testkey'
+                       ),
+                       'With underscores' => array(
+                               'this_is_a_test_extension',
+                               'tx_thisisatestextension'
+                       ),
+                       'With user prefix and without underscores' => array(
+                               'user_testkey',
+                               'user_testkey'
+                       ),
+                       'With user prefix and with underscores' => array(
+                               'user_test_key',
+                               'user_testkey'
+                       ),
+               );
+       }
+
+       /**
+        * @test
+        * @param string $extensionName
+        * @param string $expectedPrefix
+        * @dataProvider extensionKeyDataProvider
+        */
+       public function getClassNamePrefixForExtensionKey($extensionName, $expectedPrefix) {
+               $this->assertSame($expectedPrefix, ExtensionManagementUtility::getCN($extensionName));
+       }
+
        /////////////////////////////////////////////
        // Tests concerning getExtensionKeyByPrefix
        /////////////////////////////////////////////
@@ -737,6 +773,62 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                ExtensionManagementUtilityAccessibleProxy::loadSingleExtLocalconfFiles();
        }
 
+       /////////////////////////////////////////
+       // Tests concerning addModule
+       /////////////////////////////////////////
+
+       /**
+        * @test
+        */
+       public function newSubmoduleCanBeAddedToTopOfModule() {
+               $mainModule = 'foobar';
+               $subModule = 'newModule';
+               $GLOBALS['TBE_MODULES'][$mainModule] = 'some,modules';
+
+               ExtensionManagementUtility::addModule($mainModule, $subModule, 'top');
+
+               $this->assertEquals('newModule,some,modules', $GLOBALS['TBE_MODULES'][$mainModule]);
+       }
+
+       /**
+        * @test
+        */
+       public function newSubmoduleCanBeAddedToBottomOfModule() {
+               $mainModule = 'foobar';
+               $subModule = 'newModule';
+               $GLOBALS['TBE_MODULES'][$mainModule] = 'some,modules';
+
+               ExtensionManagementUtility::addModule($mainModule, $subModule, 'bottom');
+
+               $this->assertEquals('some,modules,newModule', $GLOBALS['TBE_MODULES'][$mainModule]);
+       }
+
+       /**
+        * @test
+        */
+       public function newSubmoduleCanBeAddedAfterSpecifiedSubmodule() {
+               $mainModule = 'foobar';
+               $subModule = 'newModule';
+               $GLOBALS['TBE_MODULES'][$mainModule] = 'some,modules';
+
+               ExtensionManagementUtility::addModule($mainModule, $subModule, 'after:some');
+
+               $this->assertEquals('some,newModule,modules', $GLOBALS['TBE_MODULES'][$mainModule]);
+       }
+
+       /**
+        * @test
+        */
+       public function newSubmoduleCanBeAddedBeforeSpecifiedSubmodule() {
+               $mainModule = 'foobar';
+               $subModule = 'newModule';
+               $GLOBALS['TBE_MODULES'][$mainModule] = 'some,modules';
+
+               ExtensionManagementUtility::addModule($mainModule, $subModule, 'before:modules');
+
+               $this->assertEquals('some,newModule,modules', $GLOBALS['TBE_MODULES'][$mainModule]);
+       }
+
        /////////////////////////////////////////
        // Tests concerning createExtLocalconfCacheEntry
        /////////////////////////////////////////