[FEATURE] Add possibility to use an extension as repository 72/23672/8
authorSusanne Moog <typo3@susannemoog.de>
Sat, 28 Sep 2013 16:40:51 +0000 (18:40 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 28 Sep 2013 16:55:45 +0000 (18:55 +0200)
Sometimes extensions depend on customized versions of other
extensions or on extensions that aren't released to the TER.

This feature allows an extension to deliver it's own dependencies
by having the unpacked extensions inside the folder
Initialisation/Extensions. The extensions are then copied to
typo3conf/ext when resolving the dependencies.

Resolves: #51835
Releases: 6.2
Change-Id: I66f6e5d5d40e11471f9766ac2ed9d0eb5386eb49
Reviewed-on: https://review.typo3.org/23672
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
typo3/sysext/extensionmanager/Classes/Controller/ActionController.php
typo3/sysext/extensionmanager/Classes/Domain/Model/DownloadQueue.php
typo3/sysext/extensionmanager/Classes/Domain/Model/Extension.php
typo3/sysext/extensionmanager/Classes/Service/ExtensionManagementService.php
typo3/sysext/extensionmanager/Classes/Utility/DependencyUtility.php
typo3/sysext/extensionmanager/Tests/Unit/Service/ExtensionManagementServiceTest.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/DependencyUtilityTest.php

index fee952b..4817e44 100644 (file)
@@ -3598,12 +3598,16 @@ Connection: close
        /**
         * Low level utility function to copy directories and content recursive
         *
-        * @param string $source Path to source directory, relative to document root
-        * @param string $destination Path to destination directory, relative to document root
+        * @param string $source Path to source directory, relative to document root or absolute
+        * @param string $destination Path to destination directory, relative to document root or absolute
         */
        public static function copyDirectory($source, $destination) {
-               $source = PATH_site . $source;
-               $destination = PATH_site . $destination;
+               if (strpos($source, PATH_site) === FALSE) {
+                       $source = PATH_site . $source;
+               }
+               if (strpos($destination, PATH_site) === FALSE) {
+                       $destination = PATH_site . $destination;
+               }
                if (static::isAllowedAbsPath($source) && static::isAllowedAbsPath($destination)) {
                        $iterator = new \RecursiveIteratorIterator(
                                new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
index b813c9b..953281a 100644 (file)
@@ -3887,7 +3887,7 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @test
         */
-       public function copyDirectoryCopiesFilesAndDirectories() {
+       public function copyDirectoryCopiesFilesAndDirectoriesWithRelativePaths() {
                $sourceDirectory = 'typo3temp/' . uniqid('test_') . '/';
                $absoluteSourceDirectory = PATH_site . $sourceDirectory;
                $this->testFilesToDelete[] = $absoluteSourceDirectory;
@@ -3908,6 +3908,30 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertFileExists($absoluteTargetDirectory . 'foo/file');
        }
 
+       /**
+        * @test
+        */
+       public function copyDirectoryCopiesFilesAndDirectoriesWithAbsolutePaths() {
+               $sourceDirectory = 'typo3temp/' . uniqid('test_') . '/';
+               $absoluteSourceDirectory = PATH_site . $sourceDirectory;
+               $this->testFilesToDelete[] = $absoluteSourceDirectory;
+               Utility\GeneralUtility::mkdir($absoluteSourceDirectory);
+
+               $targetDirectory = 'typo3temp/' . uniqid('test_') . '/';
+               $absoluteTargetDirectory = PATH_site . $targetDirectory;
+               $this->testFilesToDelete[] = $absoluteTargetDirectory;
+               Utility\GeneralUtility::mkdir($absoluteTargetDirectory);
+
+               Utility\GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
+               Utility\GeneralUtility::mkdir($absoluteSourceDirectory . 'foo');
+               Utility\GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'foo/file', '42');
+
+               Utility\GeneralUtility::copyDirectory($absoluteSourceDirectory, $absoluteTargetDirectory);
+
+               $this->assertFileExists($absoluteTargetDirectory . 'file');
+               $this->assertFileExists($absoluteTargetDirectory . 'foo/file');
+       }
+
        /////////////////////////////////////////////////////////////////////////////////////
        // Tests concerning sysLog
        /////////////////////////////////////////////////////////////////////////////////////
index e20e8fb..4918284 100644 (file)
@@ -47,6 +47,12 @@ class ActionController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCo
        protected $fileHandlingUtility;
 
        /**
+        * @var \TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility
+        * @inject
+        */
+       protected $extensionModelUtility;
+
+       /**
         * @var \TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService
         * @inject
         */
@@ -66,7 +72,9 @@ class ActionController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCo
                        } else {
                                // install
                                $this->managementService->resolveDependenciesAndInstall(
-                                       $this->installUtility->enrichExtensionWithDetails($extension)
+                                       $this->extensionModelUtility->mapExtensionArrayToModel(
+                                               $this->installUtility->enrichExtensionWithDetails($extension)
+                                       )
                                );
                        }
                } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
index 33f9fdd..cab8069 100644 (file)
@@ -48,6 +48,13 @@ class DownloadQueue implements \TYPO3\CMS\Core\SingletonInterface {
        protected $extensionInstallStorage = array();
 
        /**
+        * Storage for extensions to be copied
+        *
+        * @var array
+        */
+       protected $extensionCopyStorage = array();
+
+       /**
         * @var \TYPO3\CMS\Extensionmanager\Utility\ListUtility
         * @inject
         */
@@ -124,6 +131,29 @@ class DownloadQueue implements \TYPO3\CMS\Core\SingletonInterface {
        }
 
        /**
+        * Adds an extension to the copy queue for later copying
+        *
+        * @param string $extensionKey
+        * @param string $sourceFolder
+        * @return void
+        */
+       public function addExtensionToCopyQueue($extensionKey, $sourceFolder) {
+               $this->extensionCopyStorage[$extensionKey] = $sourceFolder;
+       }
+
+       /**
+        * Remove an extension from extension copy storage
+        *
+        * @param $extensionKey
+        * @return void
+        */
+       public function removeExtensionFromCopyQueue($extensionKey) {
+               if (array_key_exists($extensionKey, $this->extensionCopyStorage)) {
+                       unset($this->extensionCopyStorage[$extensionKey]);
+               }
+       }
+
+       /**
         * Gets the extension installation queue
         *
         * @return array
@@ -132,6 +162,15 @@ class DownloadQueue implements \TYPO3\CMS\Core\SingletonInterface {
                return $this->extensionInstallStorage;
        }
 
+       /**
+        * Gets the extension copy queue
+        *
+        * @return array
+        */
+       public function getExtensionCopyStorage() {
+               return $this->extensionCopyStorage;
+       }
+
 }
 
 
index 9bf4210..9ff2feb 100644 (file)
@@ -506,9 +506,9 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
         */
        public function getDependencies() {
                if (!is_object($this->dependencies)) {
-                       /** @var $dependencyUtility \TYPO3\CMS\Extensionmanager\Utility\DependencyUtility */
-                       $dependencyUtility = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility');
-                       $this->setDependencies($dependencyUtility->convertDependenciesToObjects($this->getSerializedDependencies()));
+                       /** @var $extensionModelUtility \TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility */
+                       $extensionModelUtility = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\ExtensionModelUtility');
+                       $this->setDependencies($extensionModelUtility->convertDependenciesToObjects($this->getSerializedDependencies()));
                }
                return $this->dependencies;
        }
index a6dd995..5870ebc 100644 (file)
@@ -72,6 +72,17 @@ class ExtensionManagementService implements \TYPO3\CMS\Core\SingletonInterface {
        }
 
        /**
+        * Mark an extension for copy
+        *
+        * @param string $extensionKey
+        * @param string $sourceFolder
+        * @return void
+        */
+       public function markExtensionForCopy($extensionKey, $sourceFolder) {
+               $this->downloadQueue->addExtensionToCopyQueue($extensionKey, $sourceFolder);
+       }
+
+       /**
         * Mark an extension for download
         *
         * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
@@ -92,27 +103,29 @@ class ExtensionManagementService implements \TYPO3\CMS\Core\SingletonInterface {
        }
 
        /**
-        * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|array $extension
+        * Resolve an extensions dependencys (download, copy and install dependent
+        * extensions) and install the extension
+        *
+        * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
         * @return array
         */
-       public function resolveDependenciesAndInstall($extension) {
-               if (!is_array($extension) && !$extension instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension) {
-                       throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Extension must be array or object.', 1350891642);
-               }
+       public function resolveDependenciesAndInstall(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) {
+               $downloadedDependencies = $this->downloadMainExtension($extension);
+               $extensionKey = $extension->getExtensionKey();
+               $this->setInExtensionRepository($extensionKey);
                $this->dependencyUtility->buildExtensionDependenciesTree($extension);
-               if ($extension instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension) {
-                       // We have a TER Extension, which should be downloaded first.
-                       $this->downloadQueue->addExtensionToQueue($extension);
-                       $extensionKey = $extension->getExtensionKey();
-               } else {
-                       $extensionKey = $extension['key'];
-               }
-               $queue = $this->downloadQueue->getExtensionQueue();
-               $downloadedDependencies = array();
+
                $updatedDependencies = array();
                $installedDependencies = array();
+               $queue = $this->downloadQueue->getExtensionQueue();
+               $copyQueue = $this->downloadQueue->getExtensionCopyStorage();
+
+               if (count($copyQueue) > 0) {
+                       $this->copyDependencies($copyQueue);
+               }
+
                if (array_key_exists('download', $queue)) {
-                       $downloadedDependencies = $this->downloadDependencies($queue['download']);
+                       $downloadedDependencies = array_merge($downloadedDependencies, $this->downloadDependencies($queue['download']));
                }
                if (array_key_exists('update', $queue)) {
                        $this->downloadDependencies($queue['update']);
@@ -128,6 +141,37 @@ class ExtensionManagementService implements \TYPO3\CMS\Core\SingletonInterface {
        }
 
        /**
+        * Sets the path to the repository in an extension
+        * (Initialisation/Extensions) depending on the extension
+        * that is currently installed
+        *
+        * @param string $extensionKey
+        */
+       protected function setInExtensionRepository($extensionKey) {
+               $paths = \TYPO3\CMS\Extensionmanager\Domain\Model\Extension::returnInstallPaths();
+               $path = $paths[$this->downloadUtility->getDownloadPath()];
+               $localExtensionStorage = $path . $extensionKey . '/Initialisation/Extensions/';
+               $this->dependencyUtility->setLocalExtensionStorage($localExtensionStorage);
+       }
+
+       /**
+        * Copies locally provided extensions to typo3conf/ext
+        *
+        * @param array $copyQueue
+        * @return void
+        */
+       protected function copyDependencies(array $copyQueue) {
+               $installPaths = \TYPO3\CMS\Extensionmanager\Domain\Model\Extension::returnAllowedInstallPaths();
+               foreach ($copyQueue as $extensionKey => $sourceFolder) {
+                       $destination = $installPaths['Local'] . $extensionKey;
+                       \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($destination);
+                       \TYPO3\CMS\Core\Utility\GeneralUtility::copyDirectory($sourceFolder . $extensionKey, $destination);
+                       $this->markExtensionForInstallation($extensionKey);
+                       $this->downloadQueue->removeExtensionFromCopyQueue($extensionKey);
+               }
+       }
+
+       /**
         * Uninstall extensions that will be updated
         * This is not strictly necessary but cleaner all in all
         *
@@ -194,6 +238,24 @@ class ExtensionManagementService implements \TYPO3\CMS\Core\SingletonInterface {
                return array_merge($this->downloadQueue->getExtensionQueue(), $installQueue);
        }
 
+       /**
+        * Downloads the extension the user wants to install
+        * This is separated from downloading the dependencies
+        * as an extension is able to provide it's own dependencies
+        *
+        * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
+        * @return array
+        */
+       public function downloadMainExtension(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) {
+               $downloadedDependencies = array();
+               if ($extension->getUid()) {
+                       $this->downloadQueue->addExtensionToQueue($extension);
+                       $queue = $this->downloadQueue->getExtensionQueue();
+                       $downloadedDependencies = $this->downloadDependencies($queue['download']);
+               }
+               return $downloadedDependencies;
+       }
+
 }
 
 
index 31ec797..2be5283 100644 (file)
@@ -70,6 +70,18 @@ class DependencyUtility implements \TYPO3\CMS\Core\SingletonInterface {
 
 
        /**
+        * @var string
+        */
+       protected $localExtensionStorage = '';
+
+       /**
+        * @param string $localExtensionStorage
+        */
+       public function setLocalExtensionStorage($localExtensionStorage) {
+               $this->localExtensionStorage = $localExtensionStorage;
+       }
+
+       /**
         * Setter for available extensions
         * gets available extensions from list utility if not already done
         *
@@ -80,53 +92,15 @@ class DependencyUtility implements \TYPO3\CMS\Core\SingletonInterface {
        }
 
        /**
-        * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|array $extension
+        * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
         * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
         */
-       public function buildExtensionDependenciesTree($extension) {
-               if (!is_array($extension) && !$extension instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension) {
-                       throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Extension must be array or object.', 1350891642);
-               }
-               if ($extension instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension) {
-                       $dependencies = $extension->getDependencies();
-               } else {
-                       $dependencies = $this->convertDependenciesToObjects(serialize($extension['constraints']));
-               }
+       public function buildExtensionDependenciesTree(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) {
+               $dependencies = $extension->getDependencies();
                $this->checkDependencies($dependencies);
        }
 
        /**
-        * @param string $dependencies
-        * @return \SplObjectStorage
-        */
-       public function convertDependenciesToObjects($dependencies) {
-               $unserializedDependencies = unserialize($dependencies);
-               $dependenciesObject = new \SplObjectStorage();
-               foreach ($unserializedDependencies as $dependencyType => $dependencyValues) {
-                       foreach ($dependencyValues as $dependency => $versions) {
-                               if ($dependencyType && $dependency) {
-                                       $versionNumbers = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionsStringToVersionNumbers($versions);
-                                       $lowest = $versionNumbers[0];
-                                       if (count($versionNumbers) === 2) {
-                                               $highest = $versionNumbers[1];
-                                       } else {
-                                               $highest = '';
-                                       }
-                                       /** @var $dependencyObject \TYPO3\CMS\Extensionmanager\Domain\Model\Dependency */
-                                       $dependencyObject = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency');
-                                       $dependencyObject->setType($dependencyType);
-                                       $dependencyObject->setIdentifier($dependency);
-                                       $dependencyObject->setLowestVersion($lowest);
-                                       $dependencyObject->setHighestVersion($highest);
-                                       $dependenciesObject->attach($dependencyObject);
-                                       unset($dependencyObject);
-                               }
-                       }
-               }
-               return $dependenciesObject;
-       }
-
-       /**
         * Checks dependencies for special cases (currently typo3 and php)
         *
         * @param \SplObjectStorage $dependencies
@@ -181,13 +155,22 @@ class DependencyUtility implements \TYPO3\CMS\Core\SingletonInterface {
                $lowerCaseIdentifier = strtolower($dependency->getIdentifier());
                if ($lowerCaseIdentifier === 'php') {
                        if (!($dependency->getLowestVersion() === '') && version_compare(PHP_VERSION, $dependency->getLowestVersion()) === -1) {
-                               throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Your PHP version is lower than necessary. You need at least PHP version ' . $dependency->getLowestVersion());
+                               throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException(
+                                       'Your PHP version is lower than necessary. You need at least PHP version ' . $dependency->getLowestVersion(),
+                                        1377977857
+                               );
                        }
                        if (!($dependency->getHighestVersion() === '') && version_compare($dependency->getHighestVersion(), PHP_VERSION) === -1) {
-                               throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Your PHP version is higher than allowed. You can use PHP versions ' . $dependency->getLowestVersion() . ' - ' . $dependency->getHighestVersion());
+                               throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException(
+                                       'Your PHP version is higher than allowed. You can use PHP versions ' . $dependency->getLowestVersion() . ' - ' . $dependency->getHighestVersion(),
+                                       1377977856
+                               );
                        }
                } else {
-                       throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('checkPhpDependency can only check PHP dependencies. Found dependency with identifier "' . $dependency->getIdentifier() . '"');
+                       throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException(
+                               'checkPhpDependency can only check PHP dependencies. Found dependency with identifier "' . $dependency->getIdentifier() . '"',
+                               1377977857
+                       );
                }
                return TRUE;
        }
@@ -211,7 +194,7 @@ class DependencyUtility implements \TYPO3\CMS\Core\SingletonInterface {
                        if ($isLoadedVersionCompatible === TRUE) {
                                return TRUE;
                        } else {
-                               $this->getExtensionFromTer($extensionKey, $dependency);
+                               $this->getExtensionFromRepository($extensionKey, $dependency);
                        }
                } else {
                        $extensionIsAvailable = $this->isDependentExtensionAvailable($extensionKey);
@@ -220,10 +203,42 @@ class DependencyUtility implements \TYPO3\CMS\Core\SingletonInterface {
                                if ($isAvailableVersionCompatible) {
                                        $this->managementService->markExtensionForInstallation($extensionKey);
                                } else {
-                                       $this->getExtensionFromTer($extensionKey, $dependency);
+                                       $this->getExtensionFromRepository($extensionKey, $dependency);
                                }
                        } else {
-                               $this->getExtensionFromTer($extensionKey, $dependency);
+                               $this->getExtensionFromRepository($extensionKey, $dependency);
+                       }
+               }
+               return FALSE;
+       }
+
+       /**
+        * Get an extension from a repository
+        * (might be in the extension itself or the TER)
+        *
+        * @param string $extensionKey
+        * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Dependency $dependency
+        * @return void
+        */
+       protected function getExtensionFromRepository($extensionKey, \TYPO3\CMS\Extensionmanager\Domain\Model\Dependency $dependency) {
+               if (!$this->getExtensionFromInExtensionRepository($extensionKey, $dependency)) {
+                       $this->getExtensionFromTer($extensionKey, $dependency);
+               }
+       }
+
+       /**
+        * Gets an extension from the in extension repository
+        * (the local extension storage)
+        *
+        * @param string $extensionKey
+        * @return boolean
+        */
+       protected function getExtensionFromInExtensionRepository($extensionKey) {
+               if ($this->localExtensionStorage !== '' && is_dir($this->localExtensionStorage)) {
+                       $extList = \TYPO3\CMS\Core\Utility\GeneralUtility::get_dirs($this->localExtensionStorage);
+                       if (in_array($extensionKey, $extList)) {
+                               $this->managementService->markExtensionForCopy($extensionKey, $this->localExtensionStorage);
+                               return TRUE;
                        }
                }
                return FALSE;
@@ -348,7 +363,11 @@ class DependencyUtility implements \TYPO3\CMS\Core\SingletonInterface {
         */
        protected function getLatestCompatibleExtensionByIntegerVersionDependency(\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency $dependency) {
                $versions = $this->getLowestAndHighestIntegerVersions($dependency);
-               $compatibleDataSets = $this->extensionRepository->findByVersionRangeAndExtensionKeyOrderedByVersion($dependency->getIdentifier(), $versions['lowestIntegerVersion'], $versions['highestIntegerVersion']);
+               $compatibleDataSets = $this->extensionRepository->findByVersionRangeAndExtensionKeyOrderedByVersion(
+                       $dependency->getIdentifier(),
+                       $versions['lowestIntegerVersion'],
+                       $versions['highestIntegerVersion']
+               );
                return $compatibleDataSets->getFirst();
        }
 
index 05f263f..383b777 100644 (file)
@@ -37,8 +37,9 @@ class ExtensionManagementServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseT
        public function resolveDependenciesCallsDownloadDependenciesIfDownloadKeyExistsInQueue() {
                $managementMock = $this->getAccessibleMock(
                        'TYPO3\\CMS\\Extensionmanager\\Service\\ExtensionManagementService',
-                       array('downloadDependencies', 'uninstallDependenciesToBeUpdated')
+                       array('downloadDependencies', 'uninstallDependenciesToBeUpdated', 'setInExtensionRepository', 'downloadMainExtension')
                );
+               $managementMock->expects($this->any())->method('downloadMainExtension')->will($this->returnValue(array()));
                $extensionModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
                $extensionModelMock->_set('extensionKey', 'foobar');
                $extensionModelMock->_set('version', '1.0.0');
@@ -63,8 +64,9 @@ class ExtensionManagementServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseT
        public function resolveDependenciesCallsUpdateAndDownloadDependenciesIfUpdateKeyExistsInQueue() {
                $managementMock = $this->getAccessibleMock(
                        'TYPO3\\CMS\\Extensionmanager\\Service\\ExtensionManagementService',
-                       array('downloadDependencies', 'uninstallDependenciesToBeUpdated')
+                       array('downloadDependencies', 'uninstallDependenciesToBeUpdated', 'setInExtensionRepository', 'downloadMainExtension')
                );
+               $managementMock->expects($this->any())->method('downloadMainExtension')->will($this->returnValue(array()));
                $extensionModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
                $extensionModelMock->_set('extensionKey', 'foobar');
                $extensionModelMock->_set('version', '1.0.0');
index 9a80f4b..f08e849 100644 (file)
@@ -39,123 +39,6 @@ class DependencyUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
        }
 
-       /**
-        * @test
-        * @return void
-        */
-       public function convertDependenciesToObjectsCreatesObjectStorage() {
-               $serializedDependencies = serialize(array(
-                       'depends' => array(
-                               'php' => '5.1.0-0.0.0',
-                               'typo3' => '4.2.0-4.4.99',
-                               'fn_lib' => ''
-                       )
-               ));
-               /** @var $dependencyUtility \TYPO3\CMS\Extensionmanager\Utility\DependencyUtility */
-               $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('dummy'));
-               $objectManagerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get'));
-               $dependencyModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency', array('dummy'));
-               $objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($dependencyModelMock));
-               $dependencyUtility->_set('objectManager', $objectManagerMock);
-               $objectStorage = $dependencyUtility->convertDependenciesToObjects($serializedDependencies);
-               $this->assertTrue($objectStorage instanceof \SplObjectStorage);
-       }
-
-       /**
-        * @test
-        * @return void
-        */
-       public function convertDependenciesToObjectsSetsIdentifier() {
-               $serializedDependencies = serialize(array(
-                       'depends' => array(
-                               'php' => '5.1.0-0.0.0',
-                               'typo3' => '4.2.0-4.4.99',
-                               'fn_lib' => ''
-                       )
-               ));
-               /** @var $dependencyUtility \TYPO3\CMS\Extensionmanager\Utility\DependencyUtility */
-               $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('dummy'));
-               $objectManagerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get'));
-               $dependencyModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency', array('setIdentifier'));
-               $objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($dependencyModelMock));
-               $dependencyUtility->_set('objectManager', $objectManagerMock);
-               $dependencyModelMock->expects($this->at(0))->method('setIdentifier')->with('php');
-               $dependencyModelMock->expects($this->at(1))->method('setIdentifier')->with('typo3');
-               $dependencyModelMock->expects($this->at(2))->method('setIdentifier')->with('fn_lib');
-               $dependencyUtility->convertDependenciesToObjects($serializedDependencies);
-       }
-
-       /**
-        * @return array
-        */
-       public function convertDependenciesToObjectSetsVersionDataProvider() {
-               return array(
-                       'everything ok' => array(
-                               array(
-                                       'depends' => array(
-                                               'typo3' => '4.2.0-4.4.99'
-                                       )
-                               ),
-                               array(
-                                       '4.2.0',
-                                       '4.4.99'
-                               )
-                       ),
-                       'empty high value' => array(
-                               array(
-                                       'depends' => array(
-                                               'typo3' => '4.2.0-0.0.0'
-                                       )
-                               ),
-                               array(
-                                       '4.2.0',
-                                       ''
-                               )
-                       ),
-                       'empty low value' => array(
-                               array(
-                                       'depends' => array(
-                                               'typo3' => '0.0.0-4.4.99'
-                                       )
-                               ),
-                               array(
-                                       '',
-                                       '4.4.99'
-                               )
-                       ),
-                       'only one value' => array(
-                               array(
-                                       'depends' => array(
-                                               'typo3' => '4.4.99'
-                                       )
-                               ),
-                               array(
-                                       '4.4.99',
-                                       '',
-                               )
-                       ),
-               );
-       }
-
-       /**
-        * @test         * @return void
-        * @dataProvider convertDependenciesToObjectSetsVersionDataProvider
-        * @param $dependencyString
-        * @param $returnValue
-        * @return void
-        */
-       public function convertDependenciesToObjectSetsVersion($dependencyString, $returnValue) {
-               $serializedDependencies = serialize($dependencyString);
-               /** @var $dependencyUtility \TYPO3\CMS\Extensionmanager\Utility\DependencyUtility */
-               $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('dummy'));
-               $objectManagerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get'));
-               $dependencyModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency', array('setHighestVersion', 'setLowestVersion'));
-               $objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($dependencyModelMock));
-               $dependencyUtility->_set('objectManager', $objectManagerMock);
-               $dependencyModelMock->expects($this->atLeastOnce())->method('setLowestVersion')->with($this->identicalTo($returnValue[0]));
-               $dependencyModelMock->expects($this->atLeastOnce())->method('setHighestVersion')->with($this->identicalTo($returnValue[1]));
-               $dependencyUtility->convertDependenciesToObjects($serializedDependencies);
-       }
 
        /**
         * @test