[BUGFIX] Fix tests according to changes in #57199 22/28722/2
authorHelmut Hummel <helmut.hummel@typo3.org>
Mon, 24 Mar 2014 19:09:18 +0000 (20:09 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Mon, 24 Mar 2014 19:12:41 +0000 (20:12 +0100)
Unit tests have been forgotten to be adapted,
so fix them now to make travis happy again.

Also remove the superfluous constructor
in InstallUtility, as both dependencies
are injected anyway.

Resolves: #57247
Related: #57199
Releases: 6.2
Change-Id: I40c39705c2db546b38d94936feac2c8757eed8da
Reviewed-on: https://review.typo3.org/28722
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php
typo3/sysext/extensionmanager/Tests/Unit/Service/ExtensionManagementServiceTest.php

index ba911a7..6dce0f4 100644 (file)
@@ -101,16 +101,6 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface {
        protected $registry;
 
        /**
-        * __construct
-        */
-       public function __construct() {
-               $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
-               /** @var $installToolSqlParser \TYPO3\CMS\Install\Service\SqlSchemaMigrationService */
-               $this->installToolSqlParser = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService');
-               $this->dependencyUtility = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility');
-       }
-
-       /**
         * Helper function to install an extension
         * also processes db updates and clears the cache if the extension asks for it
         *
index 37967db..881f941 100644 (file)
@@ -93,9 +93,21 @@ class ExtensionManagementServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                $managementMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Service\\ExtensionManagementService', array(
                        'dummy'
                ));
+
                $extensionModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('getExtensionKey'));
                $extensionModelMock->_set('extensionKey', 'foobar');
                $extensionModelMock->_set('version', '1.0.0');
+
+               $dependencyUtilityMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility');
+               $dependencyUtilityMock->expects($this->atLeastOnce())->method('buildExtensionDependenciesTree');
+               $installUtilityMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility');
+               $installUtilityMock->expects($this->any())->method('enrichExtensionWithDetails')->will($this->returnValue(array()));
+               $extensionModelUtilityMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ExtensionModelUtility');
+               $extensionModelUtilityMock->expects($this->any())->method('mapExtensionArrayToModel')->will($this->returnValue($extensionModelMock));
+               $managementMock->_set('dependencyUtility', $dependencyUtilityMock);
+               $managementMock->_set('installUtility', $installUtilityMock);
+               $managementMock->_set('extensionModelUtility', $extensionModelUtilityMock);
+
                $downloadQueue = array(
                        $extensionModelMock
                );
@@ -115,12 +127,24 @@ class ExtensionManagementServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                $managementMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Service\\ExtensionManagementService', array(
                        'dummy'
                ));
+
                $extensionModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('getExtensionKey'));
                $extensionModelMock->_set('extensionKey', 'foobar');
                $extensionModelMock->_set('version', '1.0.0');
                $downloadQueue = array(
                        $extensionModelMock
                );
+
+               $dependencyUtilityMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility');
+               $dependencyUtilityMock->expects($this->atLeastOnce())->method('buildExtensionDependenciesTree');
+               $installUtilityMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility');
+               $installUtilityMock->expects($this->any())->method('enrichExtensionWithDetails')->will($this->returnValue(array()));
+               $extensionModelUtilityMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ExtensionModelUtility');
+               $extensionModelUtilityMock->expects($this->any())->method('mapExtensionArrayToModel')->will($this->returnValue($extensionModelMock));
+               $managementMock->_set('dependencyUtility', $dependencyUtilityMock);
+               $managementMock->_set('installUtility', $installUtilityMock);
+               $managementMock->_set('extensionModelUtility', $extensionModelUtilityMock);
+
                $downloadQueueMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\DownloadQueue', array('removeExtensionFromQueue', 'addExtensionToInstallQueue'));
                $downloadUtilityMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DownloadUtility', array('download'));
                $downloadQueueMock->expects($this->once())->method('removeExtensionFromQueue')->with($extensionModelMock);
@@ -137,12 +161,24 @@ class ExtensionManagementServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                $managementMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Service\\ExtensionManagementService', array(
                        'dummy'
                ));
+
                $extensionModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('getExtensionKey'));
                $extensionModelMock->_set('extensionKey', 'foobar');
                $extensionModelMock->_set('version', '1.0.0');
                $downloadQueue = array(
                        $extensionModelMock
                );
+
+               $dependencyUtilityMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility');
+               $dependencyUtilityMock->expects($this->atLeastOnce())->method('buildExtensionDependenciesTree');
+               $installUtilityMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility');
+               $installUtilityMock->expects($this->any())->method('enrichExtensionWithDetails')->will($this->returnValue(array()));
+               $extensionModelUtilityMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ExtensionModelUtility');
+               $extensionModelUtilityMock->expects($this->any())->method('mapExtensionArrayToModel')->will($this->returnValue($extensionModelMock));
+               $managementMock->_set('dependencyUtility', $dependencyUtilityMock);
+               $managementMock->_set('installUtility', $installUtilityMock);
+               $managementMock->_set('extensionModelUtility', $extensionModelUtilityMock);
+
                $downloadQueueMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\DownloadQueue', array('removeExtensionFromQueue', 'addExtensionToInstallQueue'));
                $downloadUtilityMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DownloadUtility', array('download'));
                $extensionModelMock->expects($this->atLeastOnce())->method('getExtensionKey')->will($this->returnValue('foobar'));
@@ -201,7 +237,7 @@ class ExtensionManagementServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        public function installDependenciesCallsInstall() {
                $managementMock = $this->getAccessibleMock(
                        'TYPO3\\CMS\\Extensionmanager\\Service\\ExtensionManagementService',
-                       array('emitWillInstallExtensions')
+                       array('emitWillInstallExtensions', 'emitHasInstalledExtension')
                );
                $installQueue = array(
                        'foobar' => array(
@@ -224,7 +260,8 @@ class ExtensionManagementServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         */
        public function installDependenciesReturnsResolvedDependencies() {
                $managementMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Service\\ExtensionManagementService', array(
-                       'emitWillInstallExtensions'
+                       'emitWillInstallExtensions',
+                       'emitHasInstalledExtension'
                ));
                $installQueue = array(
                        'foobar' => 'foobar'