diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-12-05 13:52:51 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-12-11 12:02:11 +0100 |
commit | 770f9876595a3cebd4b911a237ec1e681bc506be (patch) | |
tree | 7e6e3dda9ccfe843d506380d5c26f6c8f38911c4 /tests | |
parent | 08f1db445134e98188f3e1e5b6b84a6eac1f6346 (diff) | |
download | nextcloud-server-770f9876595a3cebd4b911a237ec1e681bc506be.tar.gz nextcloud-server-770f9876595a3cebd4b911a237ec1e681bc506be.zip |
adding supported libraries - including min and max version
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/app/expected-info.json | 15 | ||||
-rw-r--r-- | tests/data/app/valid-info.xml | 3 | ||||
-rw-r--r-- | tests/lib/app/dependencyanalyzer.php | 46 |
3 files changed, 63 insertions, 1 deletions
diff --git a/tests/data/app/expected-info.json b/tests/data/app/expected-info.json index fc0ab224977..a425622998b 100644 --- a/tests/data/app/expected-info.json +++ b/tests/data/app/expected-info.json @@ -44,6 +44,21 @@ }, "@value": "notepad.exe" } + ], + "lib": [ + { + "@attributes" : { + "min-version": "1.2" + }, + "@value": "xml" + }, + { + "@attributes" : { + "max-version": "2.0" + }, + "@value": "intl" + }, + "curl" ] } } diff --git a/tests/data/app/valid-info.xml b/tests/data/app/valid-info.xml index f01f5fd55ea..0ea15b63a4b 100644 --- a/tests/data/app/valid-info.xml +++ b/tests/data/app/valid-info.xml @@ -25,5 +25,8 @@ <database>mysql</database> <command os="linux">grep</command> <command os="windows">notepad.exe</command> + <lib min-version="1.2">xml</lib> + <lib max-version="2.0">intl</lib> + <lib>curl</lib> </dependencies> </info> diff --git a/tests/lib/app/dependencyanalyzer.php b/tests/lib/app/dependencyanalyzer.php index a21b53264bc..872d5cfb2c5 100644 --- a/tests/lib/app/dependencyanalyzer.php +++ b/tests/lib/app/dependencyanalyzer.php @@ -43,6 +43,14 @@ class DependencyAnalyzer extends \PHPUnit_Framework_TestCase { ->will( $this->returnCallback(function($command) { return ($command === 'grep'); })); + $this->platformMock->expects($this->any()) + ->method('getLibraryVersion') + ->will( $this->returnCallback(function($lib) { + if ($lib === 'curl') { + return "2.3.4"; + } + return null; + })); $this->l10nMock = $this->getMockBuilder('\OCP\IL10N') ->disableOriginalConstructor() @@ -112,6 +120,42 @@ class DependencyAnalyzer extends \PHPUnit_Framework_TestCase { $this->assertEquals($expectedMissing, $missing); } + /** + * @dataProvider providesLibs + * @param $expectedMissing + * @param $libs + */ + function testLibs($expectedMissing, $libs) { + $app = array( + 'dependencies' => array( + ) + ); + if (!is_null($libs)) { + $app['dependencies']['lib'] = $libs; + } + + $analyser = new \OC\App\DependencyAnalyzer($app, $this->platformMock, $this->l10nMock); + $missing = $analyser->analyze(); + + $this->assertTrue(is_array($missing)); + $this->assertEquals($expectedMissing, $missing); + } + + function providesLibs() { + return array( + // we expect curl to exist + array(array(), array('curl')), + // we expect abcde to exist + array(array('The library abcde is not available.'), array('abcde')), + // curl in version 100.0 does not exist + array(array('Library curl with a version higher than 100.0 is required - available version 2.3.4.'), + array(array('@attributes' => array('min-version' => '100.0'), '@value' => 'curl'))), + // curl in version 100.0 does not exist + array(array('Library curl with a version lower than 1.0.0 is required - available version 2.3.4.'), + array(array('@attributes' => array('max-version' => '1.0.0'), '@value' => 'curl'))) + ); + } + function providesCommands() { return array( array(array(), null), @@ -142,7 +186,7 @@ class DependencyAnalyzer extends \PHPUnit_Framework_TestCase { array(array(), null, '5.5'), array(array(), '5.4', '5.5'), array(array('PHP 5.4.4 or higher is required.'), '5.4.4', null), - array(array('PHP with a version less then 5.4.2 is required.'), null, '5.4.2'), + array(array('PHP with a version lower than 5.4.2 is required.'), null, '5.4.2'), ); } } |