adding dependency to owncloud version - with fallback to requiremin and requiremax
This commit is contained in:
parent
ee46548f57
commit
5a03e0a5cf
|
@ -26,6 +26,8 @@ class DependencyAnalyzer {
|
||||||
/** @var array */
|
/** @var array */
|
||||||
private $dependencies = array();
|
private $dependencies = array();
|
||||||
|
|
||||||
|
private $appInfo = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $app
|
* @param array $app
|
||||||
* @param Platform $platform
|
* @param Platform $platform
|
||||||
|
@ -49,6 +51,7 @@ class DependencyAnalyzer {
|
||||||
$this->analyzeCommands();
|
$this->analyzeCommands();
|
||||||
$this->analyzeLibraries();
|
$this->analyzeLibraries();
|
||||||
$this->analyzeOS();
|
$this->analyzeOS();
|
||||||
|
$this->analyzeOC();
|
||||||
return $this->missing;
|
return $this->missing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +157,31 @@ class DependencyAnalyzer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function analyzeOC() {
|
||||||
|
$minVersion = null;
|
||||||
|
if (isset($this->dependencies['owncloud']['@attributes']['min-version'])) {
|
||||||
|
$minVersion = $this->dependencies['owncloud']['@attributes']['min-version'];
|
||||||
|
} elseif (isset($this->appInfo['requiremin'])) {
|
||||||
|
$minVersion = $this->appInfo['requiremin'];
|
||||||
|
}
|
||||||
|
$maxVersion = null;
|
||||||
|
if (isset($this->dependencies['oc']['@attributes']['max-version'])) {
|
||||||
|
$maxVersion = $this->dependencies['oc']['@attributes']['max-version'];
|
||||||
|
} elseif (isset($this->appInfo['requiremax'])) {
|
||||||
|
$maxVersion = $this->appInfo['requiremax'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($minVersion)) {
|
||||||
|
if (version_compare($this->platform->getOcVersion(), $minVersion, '<')) {
|
||||||
|
$this->addMissing((string)$this->l->t('ownCloud %s or higher is required.', $minVersion));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!is_null($maxVersion)) {
|
||||||
|
if (version_compare($this->platform->getOcVersion(), $maxVersion, '>')) {
|
||||||
|
$this->addMissing((string)$this->l->t('ownCloud with a version lower than %s is required.', $maxVersion));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $element
|
* @param $element
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
namespace OC\App;
|
namespace OC\App;
|
||||||
|
|
||||||
|
use OC_Util;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,6 +36,13 @@ class Platform {
|
||||||
return phpversion();
|
return phpversion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getOcVersion() {
|
||||||
|
return OC_Util::getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -60,6 +60,12 @@
|
||||||
},
|
},
|
||||||
"curl"
|
"curl"
|
||||||
],
|
],
|
||||||
"os": "Linux"
|
"os": "Linux",
|
||||||
|
"owncloud": {
|
||||||
|
"@attributes" : {
|
||||||
|
"min-version": "7.01",
|
||||||
|
"max-version": "8"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,5 +29,6 @@
|
||||||
<lib max-version="2.0">intl</lib>
|
<lib max-version="2.0">intl</lib>
|
||||||
<lib>curl</lib>
|
<lib>curl</lib>
|
||||||
<os>Linux</os>
|
<os>Linux</os>
|
||||||
|
<owncloud min-version="7.0.1" max-version="8" />
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</info>
|
</info>
|
||||||
|
|
|
@ -51,6 +51,9 @@ class DependencyAnalyzer extends \PHPUnit_Framework_TestCase {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}));
|
}));
|
||||||
|
$this->platformMock->expects($this->any())
|
||||||
|
->method('getOcVersion')
|
||||||
|
->will( $this->returnValue('8.0.1'));
|
||||||
|
|
||||||
$this->l10nMock = $this->getMockBuilder('\OCP\IL10N')
|
$this->l10nMock = $this->getMockBuilder('\OCP\IL10N')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
@ -161,6 +164,35 @@ class DependencyAnalyzer extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals($expectedMissing, $missing);
|
$this->assertEquals($expectedMissing, $missing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providesOC
|
||||||
|
* @param $expectedMissing
|
||||||
|
* @param $oc
|
||||||
|
*/
|
||||||
|
function testOC($expectedMissing, $oc) {
|
||||||
|
$app = array(
|
||||||
|
'dependencies' => array()
|
||||||
|
);
|
||||||
|
if (!is_null($oc)) {
|
||||||
|
$app['dependencies']['oc'] = $oc;
|
||||||
|
}
|
||||||
|
|
||||||
|
$analyser = new \OC\App\DependencyAnalyzer($app, $this->platformMock, $this->l10nMock);
|
||||||
|
$missing = $analyser->analyze();
|
||||||
|
|
||||||
|
$this->assertTrue(is_array($missing));
|
||||||
|
$this->assertEquals($expectedMissing, $missing);
|
||||||
|
}
|
||||||
|
|
||||||
|
function providesOC() {
|
||||||
|
return array(
|
||||||
|
// no version -> no missing dependency
|
||||||
|
array(array(), null),
|
||||||
|
array(array('ownCloud 9 or higher is required.'), array('@attributes' => array('min-version' => '9'))),
|
||||||
|
array(array('ownCloud with a version lower than 5.1.2 is required.'), array('@attributes' => array('max-version' => '5.1.2'))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function providesOS() {
|
function providesOS() {
|
||||||
return array(
|
return array(
|
||||||
array(array(), null),
|
array(array(), null),
|
||||||
|
|
Loading…
Reference in New Issue