/** @var array */
private $dependencies = array();
+ private $appInfo = array();
+
/**
* @param array $app
* @param Platform $platform
$this->analyzeCommands();
$this->analyzeLibraries();
$this->analyzeOS();
+ $this->analyzeOC();
return $this->missing;
}
}
}
+ 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
namespace OC\App;
+use OC_Util;
use OCP\IConfig;
/**
return phpversion();
}
+ /**
+ * @return string
+ */
+ public function getOcVersion() {
+ return OC_Util::getVersion();
+ }
+
/**
* @return string
*/
},
"curl"
],
- "os": "Linux"
+ "os": "Linux",
+ "owncloud": {
+ "@attributes" : {
+ "min-version": "7.01",
+ "max-version": "8"
+ }
+ }
}
}
<lib max-version="2.0">intl</lib>
<lib>curl</lib>
<os>Linux</os>
+ <owncloud min-version="7.0.1" max-version="8" />
</dependencies>
</info>
}
return null;
}));
+ $this->platformMock->expects($this->any())
+ ->method('getOcVersion')
+ ->will( $this->returnValue('8.0.1'));
$this->l10nMock = $this->getMockBuilder('\OCP\IL10N')
->disableOriginalConstructor()
$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() {
return array(
array(array(), null),