summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-12-05 14:51:41 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2014-12-11 12:02:12 +0100
commitee46548f57310b45ce723fd03ec29bfb686f8bc2 (patch)
tree8c9f08b00e1b9cd9da567439a9f90993f6d3917a
parent770f9876595a3cebd4b911a237ec1e681bc506be (diff)
downloadnextcloud-server-ee46548f57310b45ce723fd03ec29bfb686f8bc2.tar.gz
nextcloud-server-ee46548f57310b45ce723fd03ec29bfb686f8bc2.zip
adding dependencies for supported platforms
-rw-r--r--lib/private/app/dependencyanalyzer.php21
-rw-r--r--tests/data/app/expected-info.json3
-rw-r--r--tests/data/app/valid-info.xml1
-rw-r--r--tests/lib/app/dependencyanalyzer.php28
4 files changed, 52 insertions, 1 deletions
diff --git a/lib/private/app/dependencyanalyzer.php b/lib/private/app/dependencyanalyzer.php
index af36637b675..2e838872385 100644
--- a/lib/private/app/dependencyanalyzer.php
+++ b/lib/private/app/dependencyanalyzer.php
@@ -48,6 +48,7 @@ class DependencyAnalyzer {
$this->analyzeDatabases();
$this->analyzeCommands();
$this->analyzeLibraries();
+ $this->analyzeOS();
return $this->missing;
}
@@ -135,6 +136,26 @@ class DependencyAnalyzer {
}
}
+ private function analyzeOS() {
+ if (!isset($this->dependencies['os'])) {
+ return;
+ }
+
+ $oss = $this->dependencies['os'];
+ if (empty($oss)) {
+ return;
+ }
+ $oss = array_map(function($os) {
+ return $this->getValue($os);
+ }, $oss);
+ $currentOS = $this->platform->getOS();
+ if (!in_array($currentOS, $oss)) {
+ $this->addMissing((string)$this->l->t('Following platforms are supported: %s', join(', ', $oss)));
+ }
+ }
+
+
+
/**
* @param $element
* @return mixed
diff --git a/tests/data/app/expected-info.json b/tests/data/app/expected-info.json
index a425622998b..b899df7a8d6 100644
--- a/tests/data/app/expected-info.json
+++ b/tests/data/app/expected-info.json
@@ -59,6 +59,7 @@
"@value": "intl"
},
"curl"
- ]
+ ],
+ "os": "Linux"
}
}
diff --git a/tests/data/app/valid-info.xml b/tests/data/app/valid-info.xml
index 0ea15b63a4b..42f4e3edb7f 100644
--- a/tests/data/app/valid-info.xml
+++ b/tests/data/app/valid-info.xml
@@ -28,5 +28,6 @@
<lib min-version="1.2">xml</lib>
<lib max-version="2.0">intl</lib>
<lib>curl</lib>
+ <os>Linux</os>
</dependencies>
</info>
diff --git a/tests/lib/app/dependencyanalyzer.php b/tests/lib/app/dependencyanalyzer.php
index 872d5cfb2c5..1cd24193ea6 100644
--- a/tests/lib/app/dependencyanalyzer.php
+++ b/tests/lib/app/dependencyanalyzer.php
@@ -141,6 +141,34 @@ class DependencyAnalyzer extends \PHPUnit_Framework_TestCase {
$this->assertEquals($expectedMissing, $missing);
}
+ /**
+ * @dataProvider providesOS
+ * @param $expectedMissing
+ * @param $oss
+ */
+ function testOS($expectedMissing, $oss) {
+ $app = array(
+ 'dependencies' => array()
+ );
+ if (!is_null($oss)) {
+ $app['dependencies']['os'] = $oss;
+ }
+
+ $analyser = new \OC\App\DependencyAnalyzer($app, $this->platformMock, $this->l10nMock);
+ $missing = $analyser->analyze();
+
+ $this->assertTrue(is_array($missing));
+ $this->assertEquals($expectedMissing, $missing);
+ }
+
+ function providesOS() {
+ return array(
+ array(array(), null),
+ array(array(), array()),
+ array(array('Following platforms are supported: WINNT'), array('WINNT'))
+ );
+ }
+
function providesLibs() {
return array(
// we expect curl to exist