Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-12-01 23:47:22 +0300
committerThomas Müller <thomas.mueller@tmit.eu>2014-12-04 13:40:33 +0300
commitb469e9f6fb83758ad91b8e41d81319ab3a73f098 (patch)
tree5ccc10851661957739d893d914c278e1b18ff409 /tests
parentf74d568bdac14390a787a71f91571d84662f1fbe (diff)
introduce dependency analyzer to take care of app dependencies
some more unit tests on xml info parser
Diffstat (limited to 'tests')
-rw-r--r--tests/data/app/strange-types-info.json24
-rw-r--r--tests/data/app/strange-types-info.xml23
-rw-r--r--tests/lib/app/dependencyanalyzer.php77
-rw-r--r--tests/lib/app/infoparser.php21
4 files changed, 139 insertions, 6 deletions
diff --git a/tests/data/app/strange-types-info.json b/tests/data/app/strange-types-info.json
new file mode 100644
index 00000000000..eedf8bd0518
--- /dev/null
+++ b/tests/data/app/strange-types-info.json
@@ -0,0 +1,24 @@
+{
+ "info": [],
+ "remote": [],
+ "public": [],
+ "id": "files_encryption",
+ "name": "Server-side Encryption",
+ "description": "\n\tThis application encrypts all files accessed by ownCloud at rest, wherever they are stored. As an example, with this application enabled, external cloud based Amazon S3 storage will be encrypted, protecting this data on storage outside of the control of the Admin. When this application is enabled for the first time, all files are encrypted as users log in and are prompted for their password. The recommended recovery key option enables recovery of files in case the key is lost. \n\tNote that this app encrypts all files that are touched by ownCloud, so external storage providers and applications such as SharePoint will see new files encrypted when they are accessed. Encryption is based on AES 128 or 256 bit keys. More information is available in the Encryption documentation \n\t",
+ "licence": "AGPL",
+ "author": "Sam Tuke, Bjoern Schiessle, Florin Peter",
+ "requiremin": "4",
+ "shipped": "true",
+ "documentation": {
+ "user": "https://docs.example.com/server/go.php?to=user-encryption",
+ "admin": "https://docs.example.com/server/go.php?to=admin-encryption"
+ },
+ "rememberlogin": "false",
+ "types": [],
+ "ocsid": "166047",
+ "dependencies": {
+ "php": {
+ "min-version": 5.4
+ }
+ }
+}
diff --git a/tests/data/app/strange-types-info.xml b/tests/data/app/strange-types-info.xml
new file mode 100644
index 00000000000..e7e8f0d0281
--- /dev/null
+++ b/tests/data/app/strange-types-info.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<info>
+ <id>files_encryption</id>
+ <name>Server-side Encryption</name>
+ <description>
+ This application encrypts all files accessed by ownCloud at rest, wherever they are stored. As an example, with this application enabled, external cloud based Amazon S3 storage will be encrypted, protecting this data on storage outside of the control of the Admin. When this application is enabled for the first time, all files are encrypted as users log in and are prompted for their password. The recommended recovery key option enables recovery of files in case the key is lost.
+ Note that this app encrypts all files that are touched by ownCloud, so external storage providers and applications such as SharePoint will see new files encrypted when they are accessed. Encryption is based on AES 128 or 256 bit keys. More information is available in the Encryption documentation
+ </description>
+ <licence>AGPL</licence>
+ <author>Sam Tuke, Bjoern Schiessle, Florin Peter</author>
+ <requiremin>4</requiremin>
+ <shipped>true</shipped>
+ <documentation>
+ <user>user-encryption</user>
+ <admin>admin-encryption</admin>
+ </documentation>
+ <rememberlogin>false</rememberlogin>
+ <types><base/></types>
+ <ocsid>166047</ocsid>
+ <dependencies>
+ <php><min-version>5.4</min-version></php>
+ </dependencies>
+</info>
diff --git a/tests/lib/app/dependencyanalyzer.php b/tests/lib/app/dependencyanalyzer.php
new file mode 100644
index 00000000000..d0c2919f47a
--- /dev/null
+++ b/tests/lib/app/dependencyanalyzer.php
@@ -0,0 +1,77 @@
+<?php
+
+/**
+ * @author Thomas Müller
+ * @copyright 2014 Thomas Müller deepdiver@owncloud.com
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\App;
+
+use OC;
+use OC\App\Platform;
+use OCP\IL10N;
+
+class DependencyAnalyzer extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @var Platform
+ */
+ private $platformMock;
+
+ /**
+ * @var IL10N
+ */
+ private $l10nMock;
+
+ public function setUp() {
+ $this->platformMock = $this->getMockBuilder('\OC\App\Platform')
+ ->getMock();
+ $this->platformMock->expects($this->any())
+ ->method('getPhpVersion')
+ ->will( $this->returnValue('5.4.3'));
+ $this->l10nMock = $this->getMockBuilder('\OCP\IL10N')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->l10nMock->expects($this->any())
+ ->method('t')
+ ->will($this->returnCallback(function($text, $parameters = array()) {
+ return vsprintf($text, $parameters);
+ }));
+ }
+
+ /**
+ * @dataProvider providesPhpVersion
+ */
+ public function testPhpVersion($expectedMissing, $minVersion, $maxVersion) {
+ $app = array(
+ 'dependencies' => array(
+ 'php' => array()
+ )
+ );
+ if (!is_null($minVersion)) {
+ $app['dependencies']['php']['min-version'] = $minVersion;
+ }
+ if (!is_null($maxVersion)) {
+ $app['dependencies']['php']['max-version'] = $maxVersion;
+ }
+ $analyser = new \OC\App\DependencyAnalyzer($app, $this->platformMock, $this->l10nMock);
+ $missing = $analyser->analyze();
+
+ $this->assertTrue(is_array($missing));
+ $this->assertEquals(count($expectedMissing), count($missing));
+ $this->assertEquals($expectedMissing, $missing);
+ }
+
+ function providesPhpVersion() {
+ return array(
+ array(array(), null, null),
+ array(array(), '5.4', null),
+ 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'),
+ );
+ }
+}
diff --git a/tests/lib/app/infoparser.php b/tests/lib/app/infoparser.php
index 277e1582e45..20668c05086 100644
--- a/tests/lib/app/infoparser.php
+++ b/tests/lib/app/infoparser.php
@@ -39,15 +39,24 @@ class InfoParser extends \PHPUnit_Framework_TestCase {
$this->parser = new \OC\App\InfoParser($httpHelper, $urlGenerator);
}
- public function testParsingValidXml() {
- $expectedData = json_decode(file_get_contents(OC::$SERVERROOT.'/tests/data/app/expected-info.json'), true);
- $data = $this->parser->parse(OC::$SERVERROOT.'/tests/data/app/valid-info.xml');
+ /**
+ * @dataProvider providesInfoXml
+ */
+ public function testParsingValidXml($expectedJson, $xmlFile) {
+ $expectedData = null;
+ if (!is_null($expectedJson)) {
+ $expectedData = json_decode(file_get_contents(OC::$SERVERROOT . "/tests/data/app/$expectedJson"), true);
+ }
+ $data = $this->parser->parse(OC::$SERVERROOT. "/tests/data/app/$xmlFile");
$this->assertEquals($expectedData, $data);
}
- public function testParsingInvalidXml() {
- $data = $this->parser->parse(OC::$SERVERROOT.'/tests/data/app/invalid-info.xml');
- $this->assertNull($data);
+ function providesInfoXml() {
+ return array(
+ array('expected-info.json', 'valid-info.xml'),
+ array('strange-types-info.json', 'strange-types-info.xml'),
+ array(null, 'invalid-info.xml'),
+ );
}
}