single dependencies will not be represented as an array + fix unit tests

This commit is contained in:
Thomas Müller 2014-12-11 15:37:45 +01:00
parent 95fc5addec
commit 6566dc83e7
2 changed files with 24 additions and 9 deletions

View 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;
}
/**

View 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'))),
);
}