diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-07-29 09:26:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-29 09:26:25 +0200 |
commit | 54ae8eede39e58c890a42b44505a254fc5f94765 (patch) | |
tree | 66287f0ed6570034152f36a3a9deb0a446940a54 | |
parent | 937577f7bcdb779b06316487e054f1183df3d13f (diff) | |
parent | 0fcc39cd8ec7ad1ecba62ef16bb7a884fb3e9377 (diff) | |
download | nextcloud-server-54ae8eede39e58c890a42b44505a254fc5f94765.tar.gz nextcloud-server-54ae8eede39e58c890a42b44505a254fc5f94765.zip |
Merge pull request #556 from nextcloud/nextcloud-version-check
Allow apps to check for a given nextcloud version
-rw-r--r-- | lib/private/App/DependencyAnalyzer.php | 26 | ||||
-rw-r--r-- | tests/lib/App/DependencyAnalyzerTest.php | 4 |
2 files changed, 27 insertions, 3 deletions
diff --git a/lib/private/App/DependencyAnalyzer.php b/lib/private/App/DependencyAnalyzer.php index 9ccc974e3a6..7adb5d1c574 100644 --- a/lib/private/App/DependencyAnalyzer.php +++ b/lib/private/App/DependencyAnalyzer.php @@ -304,18 +304,40 @@ class DependencyAnalyzer { if (!is_null($minVersion)) { if ($this->compareSmaller($this->platform->getOcVersion(), $minVersion)) { - $missing[] = (string)$this->l->t('Server version %s or higher is required.', $minVersion); + $missing[] = (string)$this->l->t('Server version %s or higher is required.', $this->toVisibleVersion($minVersion)); } } if (!is_null($maxVersion)) { if ($this->compareBigger($this->platform->getOcVersion(), $maxVersion)) { - $missing[] = (string)$this->l->t('Server version %s or lower is required.', $maxVersion); + $missing[] = (string)$this->l->t('Server version %s or lower is required.', $this->toVisibleVersion($maxVersion)); } } return $missing; } /** + * Map the internal version number to the Nextcloud version + * + * @param string $version + * @return string + */ + protected function toVisibleVersion($version) { + switch ($version) { + case '9.1': + return '10'; + case '9.2': + return '11'; + default: + if (strpos($version, '9.1.') === 0) { + $version = '10.0.' . substr($version, 4); + } else if (strpos($version, '9.2.') === 0) { + $version = '11.0.' . substr($version, 4); + } + return $version; + } + } + + /** * @param $element * @return mixed */ diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php index 3f410444f47..684a1b52259 100644 --- a/tests/lib/App/DependencyAnalyzerTest.php +++ b/tests/lib/App/DependencyAnalyzerTest.php @@ -16,7 +16,7 @@ use Test\TestCase; class DependencyAnalyzerTest extends TestCase { - /** @var Platform */ + /** @var Platform|\PHPUnit_Framework_MockObject_MockObject */ private $platformMock; /** @var IL10N */ @@ -206,6 +206,8 @@ class DependencyAnalyzerTest extends TestCase { array(array(), array('@attributes' => array('min-version' => '8.0.2', 'max-version' => '8.0.2'))), array(array('Server version 8.0.3 or higher is required.'), array('@attributes' => array('min-version' => '8.0.3'))), array(array('Server version 9 or higher is required.'), array('@attributes' => array('min-version' => '9'))), + array(array('Server version 10 or higher is required.'), array('@attributes' => array('min-version' => '9.1'))), + array(array('Server version 11 or higher is required.'), array('@attributes' => array('min-version' => '9.2'))), [['Server version 8.0.1 or lower is required.'], ['@attributes' => ['max-version' => '8.0.1']]], ); } |