[BUGFIX] DependencyUtility does count() on an integer 76/29876/3
authorMarkus Klein <klein.t3@mfc-linz.at>
Mon, 5 May 2014 16:51:16 +0000 (18:51 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Mon, 5 May 2014 21:50:05 +0000 (23:50 +0200)
Remove the superfluous count() call.

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

index 5a0da13..31c6e0d 100644 (file)
@@ -357,7 +357,10 @@ class DependencyUtility implements \TYPO3\CMS\Core\SingletonInterface {
         */
        protected function isDownloadableVersionCompatible(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 39ebf86..5a69374 100644 (file)
@@ -344,7 +344,7 @@ class DependencyUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $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'), array($this->mockObjectManager));
-               $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);
@@ -359,7 +359,7 @@ class DependencyUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $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'), array($this->mockObjectManager));
-               $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(