[BUGFIX] addToAllTCAtypes() must replace fields correctly
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Utility / ExtensionManagementUtilityTest.php
index 5ded17d..01a39de 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 namespace TYPO3\CMS\Core\Tests\Unit\Utility;
 
-/**
+/*
  * This file is part of the TYPO3 CMS project.
  *
  * It is free software; you can redistribute it and/or modify it under
@@ -14,16 +14,22 @@ namespace TYPO3\CMS\Core\Tests\Unit\Utility;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend;
+use TYPO3\CMS\Core\Category\CategoryRegistry;
+use TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray;
+use TYPO3\CMS\Core\Package\MetaData;
+use TYPO3\CMS\Core\Package\Package;
+use TYPO3\CMS\Core\Package\PackageManager;
+use TYPO3\CMS\Core\Tests\UnitTestCase;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy;
 
 /**
- * Testcase for ExtensionManagementUtility
- *
- * @author Oliver Hader <oliver@typo3.org>
- * @author Oliver Klee <typo3-coding@oliverklee.de>
+ * Test case
  */
-class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+class ExtensionManagementUtilityTest extends UnitTestCase {
 
        /**
         * @var array A backup of registered singleton instances
@@ -35,92 +41,36 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        protected $backUpPackageManager;
 
-       public function setUp() {
+       protected function setUp() {
                $this->singletonInstances = GeneralUtility::getSingletonInstances();
-               $this->createAccessibleProxyClass();
                $this->backUpPackageManager = ExtensionManagementUtilityAccessibleProxy::getPackageManager();
                $this->singletonInstances = GeneralUtility::getSingletonInstances();
        }
 
-       public function tearDown() {
+       protected function tearDown() {
                ExtensionManagementUtility::clearExtensionKeyMap();
                ExtensionManagementUtilityAccessibleProxy::setPackageManager($this->backUpPackageManager);
                ExtensionManagementUtilityAccessibleProxy::setCacheManager(NULL);
-               $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($this->backUpPackageManager);
+               $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->backUpPackageManager);
                GeneralUtility::resetSingletonInstances($this->singletonInstances);
                parent::tearDown();
        }
 
        /**
-        * Create a subclass with protected methods made public
-        *
-        * @return void
-        * @TODO: Move this to a fixture file
-        */
-       protected function createAccessibleProxyClass() {
-               $className = 'ExtensionManagementUtilityAccessibleProxy';
-               if (!class_exists(__NAMESPACE__ . '\\' . $className, FALSE)) {
-                       eval(
-                               'namespace ' . __NAMESPACE__ . ';' .
-                               'class ' . $className . ' extends \\TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility {' .
-                               '  static public function setCacheManager(\TYPO3\CMS\Core\Cache\CacheManager $cacheManager = NULL) {' .
-                               '    static::$cacheManager = $cacheManager;' .
-                               '  }' .
-                               '  public static function getPackageManager() {' .
-                               '    return static::$packageManager;' .
-                               '  }' .
-                               '  public static function createTypo3LoadedExtensionInformationArray() {' .
-                               '    return parent::createTypo3LoadedExtensionInformationArray();' .
-                               '  }' .
-                               '  public static function getTypo3LoadedExtensionInformationCacheIdentifier() {' .
-                               '    return parent::getTypo3LoadedExtensionInformationCacheIdentifier();' .
-                               '  }' .
-                               '  public static function getExtLocalconfCacheIdentifier() {' .
-                               '    return parent::getExtLocalconfCacheIdentifier();' .
-                               '  }' .
-                               '  public static function loadSingleExtLocalconfFiles() {' .
-                               '    return parent::loadSingleExtLocalconfFiles();' .
-                               '  }' .
-                               '  public static function getBaseTcaCacheIdentifier() {' .
-                               '    return parent::getBaseTcaCacheIdentifier();' .
-                               '  }' .
-                               '  public static function resetExtTablesWasReadFromCacheOnceBoolean() {' .
-                               '    self::$extTablesWasReadFromCacheOnce = FALSE;' .
-                               '  }' .
-                               '  public static function createExtLocalconfCacheEntry() {' .
-                               '    return parent::createExtLocalconfCacheEntry();' .
-                               '  }' .
-                               '  public static function createExtTablesCacheEntry() {' .
-                               '    return parent::createExtTablesCacheEntry();' .
-                               '  }' .
-                               '  public static function getExtTablesCacheIdentifier() {' .
-                               '    return parent::getExtTablesCacheIdentifier();' .
-                               '  }' .
-                               '  public static function buildBaseTcaFromSingleFiles() {' .
-                               '    $GLOBALS[\'TCA\'] = array();' .
-                               '  }' .
-                               '  public static function emitTcaIsBeingBuiltSignal(array $tca) {' .
-                               '  }' .
-                               '}'
-                       );
-               }
-       }
-
-       /**
         * @param string $packageKey
         * @param array $packageMethods
-        * @return object
+        * @return PackageManager|\PHPUnit_Framework_MockObject_MockObject
         */
        protected function createMockPackageManagerWithMockPackage($packageKey, $packageMethods = array('getPackagePath', 'getPackageKey')) {
                $packagePath = PATH_site . 'typo3temp/' . $packageKey . '/';
                GeneralUtility::mkdir_deep($packagePath);
                $this->testFilesToDelete[] = $packagePath;
-               $package = $this->getMockBuilder('TYPO3\\CMS\\Core\\Package\\Package')
+               $package = $this->getMockBuilder(Package::class)
                                ->disableOriginalConstructor()
                                ->setMethods($packageMethods)
                                ->getMock();
                $packageManager = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Package\\PackageManager',
+                       PackageManager::class,
                        array('isPackageActive', 'getPackage', 'getActivePackages')
                );
                $package->expects($this->any())
@@ -159,7 +109,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function isLoadedReturnsFalseIfExtensionIsNotLoadedAndExitIsDisabled() {
-               $this->assertFalse(ExtensionManagementUtility::isLoaded(uniqid('foobar'), FALSE));
+               $this->assertFalse(ExtensionManagementUtility::isLoaded($this->getUniqueId('foobar'), FALSE));
        }
 
        /**
@@ -167,7 +117,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @expectedException \BadFunctionCallException
         */
        public function isLoadedThrowsExceptionIfExtensionIsNotLoaded() {
-               $this->assertFalse(ExtensionManagementUtility::isLoaded(uniqid('foobar'), TRUE));
+               $this->assertFalse(ExtensionManagementUtility::isLoaded($this->getUniqueId('foobar'), TRUE));
        }
 
        ///////////////////////////////
@@ -178,8 +128,9 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @expectedException \BadFunctionCallException
         */
        public function extPathThrowsExceptionIfExtensionIsNotLoaded() {
-               $packageName = uniqid('foo');
-               $packageManager = $this->getMock('TYPO3\\CMS\\Core\\Package\\PackageManager', array('isPackageActive'));
+               $packageName = $this->getUniqueId('foo');
+               /** @var PackageManager|\PHPUnit_Framework_MockObject_MockObject $packageManager */
+               $packageManager = $this->getMock(PackageManager::class, array('isPackageActive'));
                $packageManager->expects($this->once())
                                ->method('isPackageActive')
                                ->with($this->equalTo($packageName))
@@ -192,11 +143,12 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function extPathAppendsScriptNameToPath() {
-               $package = $this->getMockBuilder('TYPO3\\CMS\\Core\\Package\\Package')
+               $package = $this->getMockBuilder(Package::class)
                                ->disableOriginalConstructor()
                                ->setMethods(array('getPackagePath'))
                                ->getMock();
-               $packageManager = $this->getMock('TYPO3\\CMS\\Core\\Package\\PackageManager', array('isPackageActive', 'getPackage'));
+               /** @var PackageManager|\PHPUnit_Framework_MockObject_MockObject $packageManager */
+               $packageManager = $this->getMock(PackageManager::class, array('isPackageActive', 'getPackage'));
                $package->expects($this->once())
                                ->method('getPackagePath')
                                ->will($this->returnValue(PATH_site . 'foo/'));
@@ -287,17 +239,18 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        public function getExtensionKeyByPrefixForLoadedExtensionWithUnderscoresReturnsExtensionKey() {
                ExtensionManagementUtility::clearExtensionKeyMap();
-               $uniqueSuffix = uniqid('test');
+               $uniqueSuffix = $this->getUniqueId('test');
                $extensionKey = 'tt_news' . $uniqueSuffix;
                $extensionPrefix = 'tx_ttnews' . $uniqueSuffix;
-               $package = $this->getMockBuilder('TYPO3\\CMS\\Core\\Package\\Package')
+               $package = $this->getMockBuilder(Package::class)
                                ->disableOriginalConstructor()
                                ->setMethods(array('getPackageKey'))
                                ->getMock();
                $package->expects($this->exactly(2))
                                ->method('getPackageKey')
                                ->will($this->returnValue($extensionKey));
-               $packageManager = $this->getMock('TYPO3\\CMS\\Core\\Package\\PackageManager', array('getActivePackages'));
+               /** @var PackageManager|\PHPUnit_Framework_MockObject_MockObject $packageManager */
+               $packageManager = $this->getMock(PackageManager::class, array('getActivePackages'));
                $packageManager->expects($this->once())
                                ->method('getActivePackages')
                                ->will($this->returnValue(array($extensionKey => $package)));
@@ -311,17 +264,18 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        public function getExtensionKeyByPrefixForLoadedExtensionWithoutUnderscoresReturnsExtensionKey() {
                ExtensionManagementUtility::clearExtensionKeyMap();
-               $uniqueSuffix = uniqid('test');
+               $uniqueSuffix = $this->getUniqueId('test');
                $extensionKey = 'kickstarter' . $uniqueSuffix;
                $extensionPrefix = 'tx_kickstarter' . $uniqueSuffix;
-               $package = $this->getMockBuilder('TYPO3\\CMS\\Core\\Package\\Package')
+               $package = $this->getMockBuilder(Package::class)
                                ->disableOriginalConstructor()
                                ->setMethods(array('getPackageKey'))
                                ->getMock();
                $package->expects($this->exactly(2))
                                ->method('getPackageKey')
                                ->will($this->returnValue($extensionKey));
-               $packageManager = $this->getMock('TYPO3\\CMS\\Core\\Package\\PackageManager', array('getActivePackages'));
+               /** @var PackageManager|\PHPUnit_Framework_MockObject_MockObject $packageManager */
+               $packageManager = $this->getMock(PackageManager::class, array('getActivePackages'));
                $packageManager->expects($this->once())
                                ->method('getActivePackages')
                                ->will($this->returnValue(array($extensionKey => $package)));
@@ -335,8 +289,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        public function getExtensionKeyByPrefixForNotLoadedExtensionReturnsFalse() {
                ExtensionManagementUtility::clearExtensionKeyMap();
-               $uniqueSuffix = uniqid('test');
-               $extensionKey = 'unloadedextension' . $uniqueSuffix;
+               $uniqueSuffix = $this->getUniqueId('test');
                $extensionPrefix = 'tx_unloadedextension' . $uniqueSuffix;
                $this->assertFalse(ExtensionManagementUtility::getExtensionKeyByPrefix($extensionPrefix));
        }
@@ -351,7 +304,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @see ExtensionManagementUtility::addToAllTCAtypes()
         */
        public function canAddFieldsToAllTCATypesBeforeExistingOnes() {
-               $table = uniqid('tx_coretest_table');
+               $table = $this->getUniqueId('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
                ExtensionManagementUtility::addToAllTCAtypes($table, 'newA, newA, newB, fieldA', '', 'before:fieldD');
                // Checking typeA:
@@ -367,7 +320,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @see ExtensionManagementUtility::addToAllTCAtypes()
         */
        public function canAddFieldsToAllTCATypesAfterExistingOnes() {
-               $table = uniqid('tx_coretest_table');
+               $table = $this->getUniqueId('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
                ExtensionManagementUtility::addToAllTCAtypes($table, 'newA, newA, newB, fieldA', '', 'after:fieldC');
                // Checking typeA:
@@ -383,7 +336,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @see ExtensionManagementUtility::addToAllTCAtypes()
         */
        public function canAddFieldsToTCATypeBeforeExistingOnes() {
-               $table = uniqid('tx_coretest_table');
+               $table = $this->getUniqueId('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
                ExtensionManagementUtility::addToAllTCAtypes($table, 'newA, newA, newB, fieldA', 'typeA', 'before:fieldD');
                // Checking typeA:
@@ -399,7 +352,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @see ExtensionManagementUtility::addToAllTCAtypes()
         */
        public function canAddFieldsToTCATypeAfterExistingOnes() {
-               $table = uniqid('tx_coretest_table');
+               $table = $this->getUniqueId('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
                ExtensionManagementUtility::addToAllTCAtypes($table, 'newA, newA, newB, fieldA', 'typeA', 'after:fieldC');
                // Checking typeA:
@@ -415,19 +368,36 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @see ExtensionManagementUtility::addFieldsToAllPalettesOfField()
         */
        public function canAddFieldsToTCATypeAndReplaceExistingOnes() {
-               $table = uniqid('tx_coretest_table');
+               $table = $this->getUniqueId('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
                $typesBefore = $GLOBALS['TCA'][$table]['types'];
                ExtensionManagementUtility::addToAllTCAtypes($table, 'fieldZ', '', 'replace:fieldX');
                $this->assertEquals($typesBefore, $GLOBALS['TCA'][$table]['types'], 'It\'s wrong that the "types" array changes here - the replaced field is only on palettes');
                // unchanged because the palette is not used
                $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']);
-               // unchanged because the palette is not used
                $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteB']['showitem']);
+               // changed
                $this->assertEquals('fieldZ, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteC']['showitem']);
                $this->assertEquals('fieldZ, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteD']['showitem']);
        }
 
+       /**
+        * @test
+        */
+       public function addToAllTCAtypesReplacesExistingOnes() {
+               $table = $this->getUniqueId('tx_coretest_table');
+               $GLOBALS['TCA'] = $this->generateTCAForTable($table);
+               $typesBefore = $GLOBALS['TCA'][$table]['types'];
+               ExtensionManagementUtility::addToAllTCAtypes($table, 'fieldX;;foo;;', '', 'replace:fieldX');
+               $this->assertEquals($typesBefore, $GLOBALS['TCA'][$table]['types'], 'It\'s wrong that the "types" array changes here - the replaced field is only on palettes');
+               // unchanged because the palette is not used
+               $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']);
+               $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteB']['showitem']);
+               // changed
+               $this->assertEquals('fieldX;;foo;;, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteC']['showitem']);
+               $this->assertEquals('fieldX;;foo;;, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteD']['showitem']);
+       }
+
        ///////////////////////////////////////////////////
        // Tests concerning addFieldsToAllPalettesOfField
        ///////////////////////////////////////////////////
@@ -438,7 +408,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @see ExtensionManagementUtility::addFieldsToPalette()
         */
        public function canAddFieldsToPaletteBeforeExistingOnes() {
-               $table = uniqid('tx_coretest_table');
+               $table = $this->getUniqueId('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
                ExtensionManagementUtility::addFieldsToPalette($table, 'paletteA', 'newA, newA, newB, fieldX', 'before:fieldY');
                $this->assertEquals('fieldX, fieldX1, newA, newB, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']);
@@ -451,7 +421,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @see ExtensionManagementUtility::addFieldsToPalette()
         */
        public function canAddFieldsToPaletteAfterExistingOnes() {
-               $table = uniqid('tx_coretest_table');
+               $table = $this->getUniqueId('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
                ExtensionManagementUtility::addFieldsToPalette($table, 'paletteA', 'newA, newA, newB, fieldX', 'after:fieldX');
                $this->assertEquals('fieldX, newA, newB, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']);
@@ -464,20 +434,65 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @see ExtensionManagementUtility::addFieldsToPalette()
         */
        public function canAddFieldsToPaletteAfterNotExistingOnes() {
-               $table = uniqid('tx_coretest_table');
+               $table = $this->getUniqueId('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
-               ExtensionManagementUtility::addFieldsToPalette($table, 'paletteA', 'newA, newA, newB, fieldX', 'after:' . uniqid('notExisting'));
+               ExtensionManagementUtility::addFieldsToPalette($table, 'paletteA', 'newA, newA, newB, fieldX', 'after:' . $this->getUniqueId('notExisting'));
                $this->assertEquals('fieldX, fieldX1, fieldY, newA, newB', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']);
        }
 
        /**
+        * @return array
+        */
+       public function removeDuplicatesForInsertionRemovesDuplicatesDataProvider() {
+               return array(
+                       'Simple' => array(
+                               'field_b, field_d, field_c',
+                               'field_a, field_b, field_c',
+                               'field_d'
+                       ),
+                       'with linebreaks' => array(
+                               'field_b, --linebreak--, field_d, --linebreak--, field_c',
+                               'field_a, field_b, field_c',
+                               '--linebreak--, field_d, --linebreak--'
+                       ),
+                       'with linebreaks in list and insertion list' => array(
+                               'field_b, --linebreak--, field_d, --linebreak--, field_c',
+                               'field_a, field_b, --linebreak--, field_c',
+                               '--linebreak--, field_d, --linebreak--'
+                       ),
+                       'with configuration in list' => array(
+                               'field_b, field_d, field_c;;;4-4-4',
+                               'field_a, field_b;;;;2-2-2, field_c;;;;3-3-3',
+                               'field_d',
+                       ),
+                       'with configuration in list and insertion list' => array(
+                               'field_b, field_d;;;3-3-3, field_c;;;4-4-4',
+                               'field_a, field_b;;;;2-2-2, field_c;;;;3-3-3',
+                               'field_d;;;3-3-3',
+                       ),
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider removeDuplicatesForInsertionRemovesDuplicatesDataProvider
+        * @param $insertionList
+        * @param $list
+        * @param $expected
+        */
+       public function removeDuplicatesForInsertionRemovesDuplicates($insertionList, $list, $expected) {
+               $result = ExtensionManagementUtilityAccessibleProxy::removeDuplicatesForInsertion($insertionList, $list);
+               $this->assertSame($expected, $result);
+       }
+
+       /**
         * Tests whether fields can be added to all palettes of a regular field before existing ones.
         *
         * @test
         * @see ExtensionManagementUtility::addFieldsToAllPalettesOfField()
         */
        public function canAddFieldsToAllPalettesOfFieldBeforeExistingOnes() {
-               $table = uniqid('tx_coretest_table');
+               $table = $this->getUniqueId('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
                ExtensionManagementUtility::addFieldsToAllPalettesOfField($table, 'fieldC', 'newA, newA, newB, fieldX', 'before:fieldY');
                $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']);
@@ -493,7 +508,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @see ExtensionManagementUtility::addFieldsToAllPalettesOfField()
         */
        public function canAddFieldsToAllPalettesOfFieldAfterExistingOnes() {
-               $table = uniqid('tx_coretest_table');
+               $table = $this->getUniqueId('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
                ExtensionManagementUtility::addFieldsToAllPalettesOfField($table, 'fieldC', 'newA, newA, newB, fieldX', 'after:fieldX');
                $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']);
@@ -509,9 +524,9 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @see ExtensionManagementUtility::addFieldsToAllPalettesOfField()
         */
        public function canAddFieldsToAllPalettesOfFieldAfterNotExistingOnes() {
-               $table = uniqid('tx_coretest_table');
+               $table = $this->getUniqueId('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
-               ExtensionManagementUtility::addFieldsToAllPalettesOfField($table, 'fieldC', 'newA, newA, newB, fieldX', 'after:' . uniqid('notExisting'));
+               ExtensionManagementUtility::addFieldsToAllPalettesOfField($table, 'fieldC', 'newA, newA, newB, fieldX', 'after:' . $this->getUniqueId('notExisting'));
                $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']);
                $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteB']['showitem']);
                $this->assertEquals('fieldX, fieldX1, fieldY, newA, newB', $GLOBALS['TCA'][$table]['palettes']['paletteC']['showitem']);
@@ -525,7 +540,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @see ExtensionManagementUtility::addFieldsToAllPalettesOfField()
         */
        public function canAddFieldsToAllPalettesOfFieldWithoutPaletteExistingBefore() {
-               $table = uniqid('tx_coretest_table');
+               $table = $this->getUniqueId('tx_coretest_table');
                $GLOBALS['TCA'] = $this->generateTCAForTable($table);
                ExtensionManagementUtility::addFieldsToAllPalettesOfField($table, 'fieldA', 'newA, newA, newB, fieldX');
                $this->assertEquals('fieldX, fieldX1, fieldY', $GLOBALS['TCA'][$table]['palettes']['paletteA']['showitem']);
@@ -571,9 +586,11 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        /**
         * @test
         * @dataProvider executePositionedStringInsertionTrimsCorrectCharactersDataProvider
+        * @param $string
+        * @param $expectedResult
         */
        public function executePositionedStringInsertionTrimsCorrectCharacters($string, $expectedResult) {
-               $extensionManagementUtility = $this->getAccessibleMock('\\TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility', array('dummy'));
+               $extensionManagementUtility = $this->getAccessibleMock(ExtensionManagementUtility::class, array('dummy'));
                $string = $extensionManagementUtility->_call('executePositionedStringInsertion', $string, '');
                $this->assertEquals($expectedResult, $string);
        }
@@ -694,6 +711,9 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        /**
         * @test
         * @dataProvider addTcaSelectItemDataProvider
+        * @param $relativeToField
+        * @param $relativePosition
+        * @param $expectedResultArray
         */
        public function addTcaSelectItemInsertsItemAtSpecifiedPosition($relativeToField, $relativePosition, $expectedResultArray) {
                $GLOBALS['TCA'] = array(
@@ -722,10 +742,11 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function loadExtLocalconfDoesNotReadFromCacheIfCachingIsDenied() {
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->never())->method('getCache');
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
-               $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($this->createMockPackageManagerWithMockPackage(uniqid()));
+               $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->createMockPackageManagerWithMockPackage($this->getUniqueId()));
                ExtensionManagementUtility::loadExtLocalconf(FALSE);
        }
 
@@ -734,13 +755,14 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        public function loadExtLocalconfRequiresCacheFileIfExistsAndCachingIsAllowed() {
                $mockCache = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
+                       AbstractFrontend::class,
                        array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
                        array(),
                        '',
                        FALSE
                );
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                $mockCache->expects($this->any())->method('has')->will($this->returnValue(TRUE));
@@ -756,11 +778,11 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @expectedException \RuntimeException
         */
        public function loadSingleExtLocalconfFilesRequiresExtLocalconfFileRegisteredInGlobalTypo3LoadedExt() {
-               $extensionName = uniqid('foo');
+               $extensionName = $this->getUniqueId('foo');
                $packageManager = $this->createMockPackageManagerWithMockPackage($extensionName);
                $extLocalconfLocation = $packageManager->getPackage($extensionName)->getPackagePath() . 'ext_localconf.php';
                file_put_contents($extLocalconfLocation, "<?php\n\nthrow new RuntimeException('', 1340559079);\n\n?>");
-               $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($packageManager);
+               $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($packageManager);
                ExtensionManagementUtilityAccessibleProxy::loadSingleExtLocalconfFiles();
        }
 
@@ -821,6 +843,9 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        /**
         * @test
         * @dataProvider addModulePositionTestsDataProvider
+        * @param $position
+        * @param $existing
+        * @param $expected
         */
        public function addModuleCanAddModule($position, $existing, $expected) {
                $mainModule = 'foobar';
@@ -842,20 +867,21 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function createExtLocalconfCacheEntryWritesCacheEntryWithContentOfLoadedExtensionExtLocalconf() {
-               $extensionName = uniqid('foo');
+               $extensionName = $this->getUniqueId('foo');
                $packageManager = $this->createMockPackageManagerWithMockPackage($extensionName);
                $extLocalconfLocation = $packageManager->getPackage($extensionName)->getPackagePath() . 'ext_localconf.php';
-               $uniqueStringInLocalconf = uniqid('foo');
+               $uniqueStringInLocalconf = $this->getUniqueId('foo');
                file_put_contents($extLocalconfLocation, "<?php\n\n" . $uniqueStringInLocalconf . "\n\n?>");
-               $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($packageManager);
+               $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($packageManager);
                $mockCache = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
+                       AbstractFrontend::class,
                        array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
                        array(),
                        '',
                        FALSE
                );
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                $mockCache->expects($this->once())->method('set')->with($this->anything(), $this->stringContains($uniqueStringInLocalconf), $this->anything());
@@ -866,17 +892,18 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function createExtLocalconfCacheEntryWritesCacheEntryWithExtensionContentOnlyIfExtLocalconfExists() {
-               $extensionName = uniqid('foo');
+               $extensionName = $this->getUniqueId('foo');
                $packageManager = $this->createMockPackageManagerWithMockPackage($extensionName);
-               $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($packageManager);
+               $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($packageManager);
                $mockCache = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
+                       AbstractFrontend::class,
                        array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
                        array(),
                        '',
                        FALSE
                );
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                $mockCache->expects($this->once())
@@ -890,17 +917,18 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        public function createExtLocalconfCacheEntryWritesCacheEntryWithNoTags() {
                $mockCache = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
+                       AbstractFrontend::class,
                        array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
                        array(),
                        '',
                        FALSE
                );
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                $mockCache->expects($this->once())->method('set')->with($this->anything(), $this->anything(), $this->equalTo(array()));
-               $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($this->createMockPackageManagerWithMockPackage(uniqid()));
+               $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->createMockPackageManagerWithMockPackage($this->getUniqueId()));
                ExtensionManagementUtilityAccessibleProxy::createExtLocalconfCacheEntry();
        }
 
@@ -926,7 +954,8 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function loadBaseTcaDoesNotReadFromCacheIfCachingIsDenied() {
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->never())->method('getCache');
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                ExtensionManagementUtilityAccessibleProxy::loadBaseTca(FALSE);
@@ -937,13 +966,14 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        public function loadBaseTcaRequiresCacheFileIfExistsAndCachingIsAllowed() {
                $mockCache = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
+                       AbstractFrontend::class,
                        array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
                        array(),
                        '',
                        FALSE
                );
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                $mockCache->expects($this->any())->method('has')->will($this->returnValue(TRUE));
@@ -955,26 +985,27 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function loadBaseTcaCreatesCacheFileWithContentOfAnExtensionsConfigurationTcaPhpFile() {
-               $extensionName = uniqid('test_baseTca_');
+               $extensionName = $this->getUniqueId('test_baseTca_');
                $packageManager = $this->createMockPackageManagerWithMockPackage($extensionName);
                $packagePath = $packageManager->getPackage($extensionName)->getPackagePath();
                GeneralUtility::mkdir($packagePath);
                GeneralUtility::mkdir($packagePath . 'Configuration/');
                GeneralUtility::mkdir($packagePath . 'Configuration/TCA/');
-               $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($packageManager);
+               $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($packageManager);
                ExtensionManagementUtility::setPackageManager($packageManager);
-               $uniqueTableName = uniqid('table_name_');
-               $uniqueStringInTableConfiguration = uniqid('table_configuration_');
+               $uniqueTableName = $this->getUniqueId('table_name_');
+               $uniqueStringInTableConfiguration = $this->getUniqueId('table_configuration_');
                $tableConfiguration = '<?php return array(\'foo\' => \'' . $uniqueStringInTableConfiguration . '\'); ?>';
                file_put_contents($packagePath . 'Configuration/TCA/' . $uniqueTableName . '.php', $tableConfiguration);
                $mockCache = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
+                       AbstractFrontend::class,
                        array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
                        array(),
                        '',
                        FALSE
                );
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                $mockCache->expects($this->once())->method('has')->will($this->returnValue(FALSE));
@@ -987,13 +1018,14 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        public function loadBaseTcaWritesCacheEntryWithNoTags() {
                $mockCache = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
+                       AbstractFrontend::class,
                        array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
                        array(),
                        '',
                        FALSE
                );
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                $mockCache->expects($this->once())->method('has')->will($this->returnValue(FALSE));
@@ -1023,10 +1055,11 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function loadExtTablesDoesNotReadFromCacheIfCachingIsDenied() {
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->never())->method('getCache');
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
-               $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($this->createMockPackageManagerWithMockPackage(uniqid()));
+               $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->createMockPackageManagerWithMockPackage($this->getUniqueId()));
                ExtensionManagementUtility::loadExtLocalconf(FALSE);
        }
 
@@ -1035,13 +1068,14 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        public function loadExtTablesRequiresCacheFileIfExistsAndCachingIsAllowed() {
                $mockCache = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
+                       AbstractFrontend::class,
                        array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
                        array(),
                        '',
                        FALSE
                );
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                $mockCache->expects($this->any())->method('has')->will($this->returnValue(TRUE));
@@ -1059,10 +1093,10 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function createExtTablesCacheEntryWritesCacheEntryWithContentOfLoadedExtensionExtTables() {
-               $extensionName = uniqid('foo');
-               $extTablesLocation = PATH_site . 'typo3temp/' . uniqid('test_ext_tables') . '.php';
+               $extensionName = $this->getUniqueId('foo');
+               $extTablesLocation = PATH_site . 'typo3temp/' . $this->getUniqueId('test_ext_tables') . '.php';
                $this->testFilesToDelete[] = $extTablesLocation;
-               $uniqueStringInTables = uniqid('foo');
+               $uniqueStringInTables = $this->getUniqueId('foo');
                file_put_contents($extTablesLocation, "<?php\n\n$uniqueStringInTables\n\n?>");
                $GLOBALS['TYPO3_LOADED_EXT'] = array(
                        $extensionName => array(
@@ -1070,13 +1104,14 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                        )
                );
                $mockCache = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
+                       AbstractFrontend::class,
                        array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
                        array(),
                        '',
                        FALSE
                );
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                $mockCache->expects($this->once())->method('set')->with($this->anything(), $this->stringContains($uniqueStringInTables), $this->anything());
@@ -1087,18 +1122,19 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function createExtTablesCacheEntryWritesCacheEntryWithExtensionContentOnlyIfExtTablesExists() {
-               $extensionName = uniqid('foo');
+               $extensionName = $this->getUniqueId('foo');
                $GLOBALS['TYPO3_LOADED_EXT'] = array(
                        $extensionName => array(),
                );
                $mockCache = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
+                       AbstractFrontend::class,
                        array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
                        array(),
                        '',
                        FALSE
                );
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                $mockCache->expects($this->once())
@@ -1112,17 +1148,18 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        public function createExtTablesCacheEntryWritesCacheEntryWithNoTags() {
                $mockCache = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend',
+                       AbstractFrontend::class,
                        array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'),
                        array(),
                        '',
                        FALSE
                );
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('getCache'));
                $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                $mockCache->expects($this->once())->method('set')->with($this->anything(), $this->anything(), $this->equalTo(array()));
-               $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($this->createMockPackageManagerWithMockPackage(uniqid()));
+               $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->createMockPackageManagerWithMockPackage($this->getUniqueId()));
                ExtensionManagementUtilityAccessibleProxy::createExtTablesCacheEntry();
        }
 
@@ -1147,7 +1184,8 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function removeCacheFilesFlushesSystemCaches() {
-               $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('flushCachesInGroup'));
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array('flushCachesInGroup'));
                $mockCacheManager->expects($this->once())->method('flushCachesInGroup')->with('system');
                ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
                ExtensionManagementUtility::removeCacheFiles();
@@ -1210,6 +1248,8 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         * @expectedException \InvalidArgumentException
         * @dataProvider getExtensionVersionFaultyDataProvider
+        * @param $key
+        * @throws \TYPO3\CMS\Core\Package\Exception
         */
        public function getExtensionVersionForFaultyExtensionKeyThrowsException($key) {
                ExtensionManagementUtility::getExtensionVersion($key);
@@ -1220,7 +1260,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        public function getExtensionVersionForNotLoadedExtensionReturnsEmptyString() {
                ExtensionManagementUtility::clearExtensionKeyMap();
-               $uniqueSuffix = uniqid('test');
+               $uniqueSuffix = $this->getUniqueId('test');
                $extensionKey = 'unloadedextension' . $uniqueSuffix;
                $this->assertEquals('', ExtensionManagementUtility::getExtensionVersion($extensionKey));
        }
@@ -1230,20 +1270,9 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        public function getExtensionVersionForLoadedExtensionReturnsExtensionVersion() {
                ExtensionManagementUtility::clearExtensionKeyMap();
-               $className = uniqid('ExtensionManagementUtility');
-               eval(
-                       'namespace ' . __NAMESPACE__ . ';' .
-                       'class ' . $className . ' extends \\TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility {' .
-                       '  public static function isLoaded() {' .
-                       '    return TRUE;' .
-                       '  }' .
-                       '}'
-               );
-               $className = __NAMESPACE__ . '\\' . $className;
-               ExtensionManagementUtility::clearExtensionKeyMap();
-               $uniqueSuffix = uniqid('test');
+               $uniqueSuffix = $this->getUniqueId('test');
                $extensionKey = 'unloadedextension' . $uniqueSuffix;
-               $packageMetaData = $this->getMock('TYPO3\\Flow\\Package\\MetaData', array('getVersion'), array($extensionKey));
+               $packageMetaData = $this->getMock(MetaData::class, array('getVersion'), array($extensionKey));
                $packageMetaData->expects($this->any())->method('getVersion')->will($this->returnValue('1.2.3'));
                $packageManager = $this->createMockPackageManagerWithMockPackage($extensionKey, array('getPackagePath', 'getPackageKey', 'getPackageMetaData'));
                /** @var \PHPUnit_Framework_MockObject_MockObject $package */
@@ -1263,7 +1292,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @expectedException \RuntimeException
         */
        public function loadExtensionThrowsExceptionIfExtensionIsLoaded() {
-               $extensionKey = uniqid('test');
+               $extensionKey = $this->getUniqueId('test');
                $packageManager = $this->createMockPackageManagerWithMockPackage($extensionKey);
                ExtensionManagementUtility::setPackageManager($packageManager);
                ExtensionManagementUtility::loadExtension($extensionKey);
@@ -1277,8 +1306,9 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @expectedException \RuntimeException
         */
        public function unloadExtensionThrowsExceptionIfExtensionIsNotLoaded() {
-               $packageName = uniqid('foo');
-               $packageManager = $this->getMock('TYPO3\\CMS\\Core\\Package\\PackageManager', array('isPackageActive'));
+               $packageName = $this->getUniqueId('foo');
+               /** @var PackageManager|\PHPUnit_Framework_MockObject_MockObject $packageManager */
+               $packageManager = $this->getMock(PackageManager::class, array('isPackageActive'));
                $packageManager->expects($this->once())
                        ->method('isPackageActive')
                        ->with($this->equalTo($packageName))
@@ -1291,9 +1321,10 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function unloadExtensionCallsPackageManagerToDeactivatePackage() {
-               $packageName = uniqid('foo');
+               $packageName = $this->getUniqueId('foo');
+               /** @var PackageManager|\PHPUnit_Framework_MockObject_MockObject $packageManager */
                $packageManager = $this->getMock(
-                       'TYPO3\\CMS\\Core\\Package\\PackageManager',
+                       PackageManager::class,
                        array('isPackageActive', 'deactivatePackage')
                );
                $packageManager->expects($this->any())
@@ -1313,12 +1344,13 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function doesMakeCategorizableCallsTheCategoryRegistryWithDefaultFieldName() {
-               $extensionKey = uniqid('extension');
-               $tableName = uniqid('table');
+               $extensionKey = $this->getUniqueId('extension');
+               $tableName = $this->getUniqueId('table');
 
-               $registryMock = $this->getMock('TYPO3\\CMS\\Core\\Category\\CategoryRegistry');
+               /** @var CategoryRegistry|\PHPUnit_Framework_MockObject_MockObject $registryMock */
+               $registryMock = $this->getMock(CategoryRegistry::class);
                $registryMock->expects($this->once())->method('add')->with($extensionKey, $tableName, 'categories', array());
-               GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Category\\CategoryRegistry', $registryMock);
+               GeneralUtility::setSingletonInstance(CategoryRegistry::class, $registryMock);
                ExtensionManagementUtility::makeCategorizable($extensionKey, $tableName);
        }
 
@@ -1326,13 +1358,14 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @test
         */
        public function doesMakeCategorizableCallsTheCategoryRegistryWithFieldName() {
-               $extensionKey = uniqid('extension');
-               $tableName = uniqid('table');
-               $fieldName = uniqid('field');
+               $extensionKey = $this->getUniqueId('extension');
+               $tableName = $this->getUniqueId('table');
+               $fieldName = $this->getUniqueId('field');
 
-               $registryMock = $this->getMock('TYPO3\\CMS\\Core\\Category\\CategoryRegistry');
+               /** @var CategoryRegistry|\PHPUnit_Framework_MockObject_MockObject $registryMock */
+               $registryMock = $this->getMock(CategoryRegistry::class);
                $registryMock->expects($this->once())->method('add')->with($extensionKey, $tableName, $fieldName, array());
-               GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Category\\CategoryRegistry', $registryMock);
+               GeneralUtility::setSingletonInstance(CategoryRegistry::class, $registryMock);
                ExtensionManagementUtility::makeCategorizable($extensionKey, $tableName, $fieldName);
        }
 
@@ -1343,7 +1376,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        /**
         * @test
         */
-       public function addPluginSetsTcaCorrectlyForGivenExtkeyAsParameter() {
+       public function addPluginSetsTcaCorrectlyForGivenExtKeyAsParameter() {
                $extKey = 'indexed_search';
                $GLOBALS['TYPO3_LOADED_EXT'] = array();
                $GLOBALS['TYPO3_LOADED_EXT'][$extKey]['ext_icon'] = 'foo.gif';
@@ -1362,7 +1395,7 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        /**
         * @test
         */
-       public function addPluginSetsTcaCorrectlyForGivenExtkeyAsGlobal() {
+       public function addPluginSetsTcaCorrectlyForGivenExtKeyAsGlobal() {
                $extKey = 'indexed_search';
                $GLOBALS['TYPO3_LOADED_EXT'] = array();
                $GLOBALS['TYPO3_LOADED_EXT'][$extKey]['ext_icon'] = 'foo.gif';
@@ -1386,4 +1419,5 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        public function addPluginThrowsExceptionForMissingExtkey() {
                ExtensionManagementUtility::addPlugin('test');
        }
+
 }