[BUGFIX] DependencyUtility does count() on an integer 83/29883/2
authorMarkus Klein <klein.t3@mfc-linz.at>
Mon, 5 May 2014 21:56:00 +0000 (23:56 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Wed, 14 May 2014 08:55:36 +0000 (10:55 +0200)
Remove the superfluous count() call.

Resolves: #58529
Releases: 6.2, 6.1, 6.0
Change-Id: I0933650b52063009de52268034480f6e06af56ac
Reviewed-on: https://review.typo3.org/29883
Tested-by: Stefan Neufeind
Reviewed-by: Markus Klein
Reviewed-by: Nicole Cordes
Tested-by: Nicole Cordes
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/extensionmanager/Classes/Utility/DependencyUtility.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/DependencyUtilityTest.php

index b57f0a5..69918a0 100644 (file)
@@ -371,7 +371,10 @@ class DependencyUtility implements \TYPO3\CMS\Core\SingletonInterface {
         */
        protected function isDownloadableVersionCompatible(\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency $dependency) {
                $versions = $this->getLowestAndHighestIntegerVersions($dependency);
-               return count($this->extensionRepository->countByVersionRangeAndExtensionKey($dependency->getIdentifier(), $versions['lowestIntegerVersion'], $versions['highestIntegerVersion'])) > 0;
+               $count = $this->extensionRepository->countByVersionRangeAndExtensionKey(
+                       $dependency->getIdentifier(), $versions['lowestIntegerVersion'], $versions['highestIntegerVersion']
+               );
+               return !empty($count);
        }
 
        /**
index b42a7bb..52816aa 100644 (file)
@@ -452,7 +452,7 @@ class DependencyUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $dependencyModelMock->expects($this->once())->method('getHighestVersion')->will($this->returnValue('10.0.0'));
                $dependencyModelMock->expects($this->once())->method('getLowestVersion')->will($this->returnValue('1.0.0'));
                $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('countByVersionRangeAndExtensionKey'));
-               $extensionRepositoryMock->expects($this->once())->method('countByVersionRangeAndExtensionKey')->with('dummy', 1000000, 10000000)->will($this->returnValue(array('1234', '5678')));
+               $extensionRepositoryMock->expects($this->once())->method('countByVersionRangeAndExtensionKey')->with('dummy', 1000000, 10000000)->will($this->returnValue(2));
                $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('dummy'));
                $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
                $count = $dependencyUtility->_call('isDownloadableVersionCompatible', $dependencyModelMock);
@@ -467,7 +467,7 @@ class DependencyUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $dependencyModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency', array('getIdentifier'));
                $dependencyModelMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('dummy'));
                $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('countByVersionRangeAndExtensionKey'));
-               $extensionRepositoryMock->expects($this->once())->method('countByVersionRangeAndExtensionKey')->with('dummy', 1000000, 2000000)->will($this->returnValue(array()));
+               $extensionRepositoryMock->expects($this->once())->method('countByVersionRangeAndExtensionKey')->with('dummy', 1000000, 2000000)->will($this->returnValue(0));
                $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('getLowestAndHighestIntegerVersions'));
                $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
                $dependencyUtility->expects($this->once())->method('getLowestAndHighestIntegerVersions')->will($this->returnValue(array(