From: Thomas Müller Date: Thu, 11 Dec 2014 14:37:45 +0000 (+0100) Subject: single dependencies will not be represented as an array + fix unit tests X-Git-Tag: v8.0.0alpha1~88^2~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6566dc83e798b0956c1646b0a4e91873cc08bb9a;p=nextcloud-server.git single dependencies will not be represented as an array + fix unit tests --- diff --git a/lib/private/app/dependencyanalyzer.php b/lib/private/app/dependencyanalyzer.php index 795017e2b37..92f65be1cd2 100644 --- a/lib/private/app/dependencyanalyzer.php +++ b/lib/private/app/dependencyanalyzer.php @@ -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; } /** diff --git a/tests/lib/app/dependencyanalyzer.php b/tests/lib/app/dependencyanalyzer.php index 9c5db96e045..8443dc5d319 100644 --- a/tests/lib/app/dependencyanalyzer.php +++ b/tests/lib/app/dependencyanalyzer.php @@ -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'))), ); }