]> source.dussan.org Git - nextcloud-server.git/commitdiff
adding dependencies for supported platforms
authorThomas Müller <thomas.mueller@tmit.eu>
Fri, 5 Dec 2014 13:51:41 +0000 (14:51 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Thu, 11 Dec 2014 11:02:12 +0000 (12:02 +0100)
lib/private/app/dependencyanalyzer.php
tests/data/app/expected-info.json
tests/data/app/valid-info.xml
tests/lib/app/dependencyanalyzer.php

index af36637b675899a04717df886b77ee4a90232013..2e8388723850b93f7e83f6ad82b726ee929a4fe3 100644 (file)
@@ -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
index a425622998bdff5c8757b4bbcec987ca80a4c251..b899df7a8d6923339bd1fc094064ca001df96a36 100644 (file)
@@ -59,6 +59,7 @@
                                "@value": "intl"
                        },
                        "curl"
-               ]
+               ],
+               "os": "Linux"
        }
 }
index 0ea15b63a4b9c5794ff8cfb4c6689f8332d31913..42f4e3edb7fea5770d9d000b0e03f3801d55fe22 100644 (file)
@@ -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>
index 872d5cfb2c55283c54c679d1bc5a9ced803c82bd..1cd24193ea678d57b332c122f9d00234d8471352 100644 (file)
@@ -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