]> source.dussan.org Git - nextcloud-server.git/commitdiff
single dependencies will not be represented as an array + fix unit tests
authorThomas Müller <thomas.mueller@tmit.eu>
Thu, 11 Dec 2014 14:37:45 +0000 (15:37 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Thu, 11 Dec 2014 14:37:45 +0000 (15:37 +0100)
lib/private/app/dependencyanalyzer.php
tests/lib/app/dependencyanalyzer.php

index 795017e2b37b7a04527f4dd9338266d7c90bd373..92f65be1cd2318660714cc8d4ba4ead3b392c841 100644 (file)
@@ -79,6 +79,9 @@ class DependencyAnalyzer {
                if (empty($supportedDatabases)) {
                        return;
                }
+               if (!is_array($supportedDatabases)) {
+                       $supportedDatabases = array($supportedDatabases);
+               }
                $supportedDatabases = array_map(function($db) {
                        return $this->getValue($db);
                }, $supportedDatabases);
@@ -94,6 +97,9 @@ class DependencyAnalyzer {
                }
 
                $commands = $this->dependencies['command'];
+               if (!is_array($commands)) {
+                       $commands = array($commands);
+               }
                $os = $this->platform->getOS();
                foreach($commands as $command) {
                        if (isset($command['@attributes']['os']) && $command['@attributes']['os'] !== $os) {
@@ -112,6 +118,9 @@ class DependencyAnalyzer {
                }
 
                $libs = $this->dependencies['lib'];
+               if (!is_array($libs)) {
+                       $libs = array($libs);
+               }
                foreach($libs as $lib) {
                        $libName = $this->getValue($lib);
                        $libVersion = $this->platform->getLibraryVersion($libName);
@@ -148,9 +157,13 @@ class DependencyAnalyzer {
                if (empty($oss)) {
                        return;
                }
-               $oss = array_map(function($os) {
-                       return $this->getValue($os);
-               }, $oss);
+               if (is_array($oss)) {
+                       $oss = array_map(function ($os) {
+                               return $this->getValue($os);
+                       }, $oss);
+               } else {
+                       $oss = array($oss);
+               }
                $currentOS = $this->platform->getOS();
                if (!in_array($currentOS, $oss)) {
                        $this->addMissing((string)$this->l->t('Following platforms are supported: %s', join(', ', $oss)));
@@ -165,8 +178,8 @@ class DependencyAnalyzer {
                        $minVersion = $this->appInfo['requiremin'];
                }
                $maxVersion = null;
-               if (isset($this->dependencies['oc']['@attributes']['max-version'])) {
-                       $maxVersion = $this->dependencies['oc']['@attributes']['max-version'];
+               if (isset($this->dependencies['owncloud']['@attributes']['max-version'])) {
+                       $maxVersion = $this->dependencies['owncloud']['@attributes']['max-version'];
                } elseif (isset($this->appInfo['requiremax'])) {
                        $maxVersion = $this->appInfo['requiremax'];
                }
@@ -190,7 +203,7 @@ class DependencyAnalyzer {
        private function getValue($element) {
                if (isset($element['@value']))
                        return $element['@value'];
-               return strval($element);
+               return (string)$element;
        }
 
        /**
index 9c5db96e04560726a7a7df60a2d85b88a778a096..8443dc5d319a75a3af49001bea8eda702ce8abcc 100644 (file)
@@ -174,7 +174,7 @@ class DependencyAnalyzer extends \PHPUnit_Framework_TestCase {
                        'dependencies' => array()
                );
                if (!is_null($oc)) {
-                       $app['dependencies']['oc'] = $oc;
+                       $app['dependencies']['owncloud'] = $oc;
                }
 
                $analyser = new \OC\App\DependencyAnalyzer($app, $this->platformMock, $this->l10nMock);
@@ -197,6 +197,7 @@ class DependencyAnalyzer extends \PHPUnit_Framework_TestCase {
                return array(
                        array(array(), null),
                        array(array(), array()),
+                       array(array('Following platforms are supported: ANDROID'), 'ANDROID'),
                        array(array('Following platforms are supported: WINNT'), array('WINNT'))
                );
        }
@@ -204,7 +205,7 @@ class DependencyAnalyzer extends \PHPUnit_Framework_TestCase {
        function providesLibs() {
                return array(
                        // we expect curl to exist
-                       array(array(), array('curl')),
+                       array(array(), 'curl'),
                        // we expect abcde to exist
                        array(array('The library abcde is not available.'), array('abcde')),
                        // curl in version 100.0 does not exist
@@ -226,7 +227,7 @@ class DependencyAnalyzer extends \PHPUnit_Framework_TestCase {
                        // we don't care about tools on Windows - we are on Linux
                        array(array(), array(array('@attributes' => array('os' => 'Windows'), '@value' => 'grepp'))),
                        // grep is known on all systems
-                       array(array(), array('grep')),
+                       array(array(), 'grep'),
                );
        }
 
@@ -235,6 +236,7 @@ class DependencyAnalyzer extends \PHPUnit_Framework_TestCase {
                        // non BC - in case on databases are defined -> all are supported
                        array(array(), null),
                        array(array(), array()),
+                       array(array('Following databases are supported: mongodb'), 'mongodb'),
                        array(array('Following databases are supported: sqlite, postgres'), array('sqlite', array('@value' => 'postgres'))),
                );
        }