예제 #1
0
 private function analyzeOC($dependencies, $appInfo)
 {
     $missing = [];
     $minVersion = null;
     if (isset($dependencies['owncloud']['@attributes']['min-version'])) {
         $minVersion = $dependencies['owncloud']['@attributes']['min-version'];
     } elseif (isset($appInfo['requiremin'])) {
         $minVersion = $appInfo['requiremin'];
     } elseif (isset($appInfo['require'])) {
         $minVersion = $appInfo['require'];
     }
     $maxVersion = null;
     if (isset($dependencies['owncloud']['@attributes']['max-version'])) {
         $maxVersion = $dependencies['owncloud']['@attributes']['max-version'];
     } elseif (isset($appInfo['requiremax'])) {
         $maxVersion = $appInfo['requiremax'];
     }
     if (!is_null($minVersion)) {
         if ($this->compareSmaller($this->platform->getOcVersion(), $minVersion)) {
             $missing[] = (string) $this->l->t('ownCloud %s or higher is required.', $minVersion);
         }
     }
     if (!is_null($maxVersion)) {
         if ($this->compareBigger($this->platform->getOcVersion(), $maxVersion)) {
             $missing[] = (string) $this->l->t('ownCloud with a version lower than %s is required.', $maxVersion);
         }
     }
     return $missing;
 }
 public function setUp()
 {
     $this->platformMock = $this->getMockBuilder('\\OC\\App\\Platform')->disableOriginalConstructor()->getMock();
     $this->platformMock->expects($this->any())->method('getPhpVersion')->will($this->returnValue('5.4.3'));
     $this->platformMock->expects($this->any())->method('getIntSize')->will($this->returnValue('4'));
     $this->platformMock->expects($this->any())->method('getDatabase')->will($this->returnValue('mysql'));
     $this->platformMock->expects($this->any())->method('getOS')->will($this->returnValue('Linux'));
     $this->platformMock->expects($this->any())->method('isCommandKnown')->will($this->returnCallback(function ($command) {
         return $command === 'grep';
     }));
     $this->platformMock->expects($this->any())->method('getLibraryVersion')->will($this->returnCallback(function ($lib) {
         if ($lib === 'curl') {
             return "2.3.4";
         }
         return null;
     }));
     $this->platformMock->expects($this->any())->method('getOcVersion')->will($this->returnValue('8.0.2'));
     $this->l10nMock = $this->getMockBuilder('\\OCP\\IL10N')->disableOriginalConstructor()->getMock();
     $this->l10nMock->expects($this->any())->method('t')->will($this->returnCallback(function ($text, $parameters = array()) {
         return vsprintf($text, $parameters);
     }));
     $this->analyser = new \OC\App\DependencyAnalyzer($this->platformMock, $this->l10nMock);
 }