summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-10-31 11:07:54 +0100
committerLukas Reschke <lukas@statuscode.ch>2016-10-31 17:17:47 +0100
commit8acb54aa0b32a8b750f8ab3aba9f63aa931be7d1 (patch)
treeaf744fe68adce931a8bb1b5918c93210b828124e /tests
parentdf7fd2b57cb211b3a6a9febdca4ab0a21baed19d (diff)
downloadnextcloud-server-8acb54aa0b32a8b750f8ab3aba9f63aa931be7d1.tar.gz
nextcloud-server-8acb54aa0b32a8b750f8ab3aba9f63aa931be7d1.zip
Add update support
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/App/DependencyAnalyzerTest.php227
-rw-r--r--tests/lib/AppTest.php34
-rw-r--r--tests/lib/InstallerTest.php91
-rw-r--r--tests/lib/ServerTest.php4
4 files changed, 279 insertions, 77 deletions
diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php
index c41829b796b..fd44954eaf4 100644
--- a/tests/lib/App/DependencyAnalyzerTest.php
+++ b/tests/lib/App/DependencyAnalyzerTest.php
@@ -1,9 +1,10 @@
<?php
-
/**
* @author Thomas Müller
+ * @author Lukas Reschke
* @copyright 2014 Thomas Müller deepdiver@owncloud.com
- * later.
+ * @copyright 2016 Lukas Reschke <lukas@statuscode.ch>
+ *
* See the COPYING-README file.
*/
@@ -187,7 +188,7 @@ class DependencyAnalyzerTest extends TestCase {
'dependencies' => array()
);
if (!is_null($oc)) {
- $app['dependencies']['owncloud'] = $oc;
+ $app['dependencies'] = $oc;
}
$missing = $this->analyser->analyze($app);
@@ -200,18 +201,216 @@ class DependencyAnalyzerTest extends TestCase {
* @return array
*/
function providesOC() {
- return array(
+ return [
// no version -> no missing dependency
- array(array(), null),
- array(array(), array('@attributes' => array('min-version' => '8', 'max-version' => '8'))),
- array(array(), array('@attributes' => array('min-version' => '8.0', 'max-version' => '8.0'))),
- 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']]],
- );
+ [
+ [],
+ null,
+ ],
+ [
+ [],
+ [
+ 'nextcloud' => [
+ '@attributes' => [
+ 'min-version' => '8',
+ 'max-version' => '8',
+ ],
+ ],
+ ],
+ ],
+ [
+ [],
+ [
+ 'nextcloud' => [
+ '@attributes' => [
+ 'min-version' => '8.0',
+ 'max-version' => '8.0',
+ ],
+ ],
+ ],
+ ],
+ [
+ [],
+ [
+ 'nextcloud' => [
+ '@attributes' => [
+ 'min-version' => '8.0.2',
+ 'max-version' => '8.0.2'
+ ],
+ ],
+ ],
+ ],
+ [
+ [
+ 'Server version 8.0.3 or higher is required.',
+ ],
+ [
+ 'nextcloud' => [
+ '@attributes' => [
+ 'min-version' => '8.0.3'
+ ],
+ ],
+ ],
+ ],
+ [
+ [
+ 'Server version 9 or higher is required.',
+ ],
+ [
+ 'nextcloud' => [
+ '@attributes' => [
+ 'min-version' => '9'
+ ],
+ ],
+ ],
+ ],
+ [
+ [
+ 'Server version 10 or higher is required.',
+ ],
+ [
+ 'nextcloud' => [
+ '@attributes' => [
+ 'min-version' => '10'
+ ],
+ ],
+ 'owncloud' => [
+ '@attributes' => [
+ 'min-version' => '9'
+ ],
+ ],
+ ],
+ ],
+ [
+ [
+ 'Server version 10 or higher is required.',
+ ],
+ [
+ 'nextcloud' => [
+ '@attributes' => [
+ 'min-version' => '9.1',
+ ],
+ ],
+ ],
+ ],
+ [
+ [
+ 'Server version 11 or higher is required.',
+ ],
+ [
+ 'nextcloud' => [
+ '@attributes' => [
+ 'min-version' => '9.2',
+ ],
+ ],
+ ],
+ ],
+ [
+ [
+ 'Server version 8.0.1 or lower is required.',
+ ],
+ [
+ 'nextcloud' => [
+ '@attributes' => [
+ 'max-version' => '8.0.1',
+ ],
+ ],
+ ],
+ ],
+ [
+ [],
+ [
+ 'owncloud' => [
+ '@attributes' => [
+ 'min-version' => '8',
+ 'max-version' => '8',
+ ],
+ ],
+ ],
+ ],
+ [
+ [],
+ [
+ 'owncloud' => [
+ '@attributes' => [
+ 'min-version' => '8.0',
+ 'max-version' => '8.0',
+ ],
+ ],
+ ],
+ ],
+ [
+ [],
+ [
+ 'owncloud' => [
+ '@attributes' => [
+ 'min-version' => '8.0.2',
+ 'max-version' => '8.0.2'
+ ],
+ ],
+ ],
+ ],
+ [
+ [
+ 'Server version 8.0.3 or higher is required.',
+ ],
+ [
+ 'owncloud' => [
+ '@attributes' => [
+ 'min-version' => '8.0.3'
+ ],
+ ],
+ ],
+ ],
+ [
+ [
+ 'Server version 9 or higher is required.',
+ ],
+ [
+ 'owncloud' => [
+ '@attributes' => [
+ 'min-version' => '9'
+ ],
+ ],
+ ],
+ ],
+ [
+ [
+ 'Server version 10 or higher is required.',
+ ],
+ [
+ 'owncloud' => [
+ '@attributes' => [
+ 'min-version' => '9.1',
+ ],
+ ],
+ ],
+ ],
+ [
+ [
+ 'Server version 11 or higher is required.',
+ ],
+ [
+ 'owncloud' => [
+ '@attributes' => [
+ 'min-version' => '9.2',
+ ],
+ ],
+ ],
+ ],
+ [
+ [
+ 'Server version 8.0.1 or lower is required.',
+ ],
+ [
+ 'owncloud' => [
+ '@attributes' => [
+ 'max-version' => '8.0.1',
+ ],
+ ],
+ ],
+ ],
+ ];
}
/**
diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php
index b7263adb78b..971d86cf6a4 100644
--- a/tests/lib/AppTest.php
+++ b/tests/lib/AppTest.php
@@ -264,6 +264,40 @@ class AppTest extends \Test\TestCase {
),
true
),
+ [
+ '9.2.0.0',
+ [
+ 'dependencies' => [
+ 'owncloud' => [
+ '@attributes' => [
+ 'min-version' => '9.0',
+ 'max-version' => '9.1',
+ ],
+ ],
+ 'nextcloud' => [
+ '@attributes' => [
+ 'min-version' => '9.1',
+ 'max-version' => '9.2',
+ ],
+ ],
+ ],
+ ],
+ true
+ ],
+ [
+ '9.2.0.0',
+ [
+ 'dependencies' => [
+ 'nextcloud' => [
+ '@attributes' => [
+ 'min-version' => '9.1',
+ 'max-version' => '9.2',
+ ],
+ ],
+ ],
+ ],
+ true
+ ],
);
}
diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php
index 11c0e2675b1..fb19ee94aa3 100644
--- a/tests/lib/InstallerTest.php
+++ b/tests/lib/InstallerTest.php
@@ -9,6 +9,7 @@
namespace Test;
+use OC\Archive\ZIP;
use OC\Installer;
class InstallerTest extends TestCase {
@@ -22,80 +23,44 @@ class InstallerTest extends TestCase {
$config = \OC::$server->getConfig();
$this->appstore = $config->setSystemValue('appstoreenabled', true);
$config->setSystemValue('appstoreenabled', true);
- Installer::removeApp(self::$appid);
+ $installer = new Installer(
+ \OC::$server->getAppFetcher(),
+ \OC::$server->getHTTPClientService(),
+ \OC::$server->getTempManager(),
+ \OC::$server->getLogger()
+ );
+ $installer->removeApp(self::$appid);
}
protected function tearDown() {
- Installer::removeApp(self::$appid);
+ $installer = new Installer(
+ \OC::$server->getAppFetcher(),
+ \OC::$server->getHTTPClientService(),
+ \OC::$server->getTempManager(),
+ \OC::$server->getLogger()
+ );
+ $installer->removeApp(self::$appid);
\OC::$server->getConfig()->setSystemValue('appstoreenabled', $this->appstore);
parent::tearDown();
}
public function testInstallApp() {
- $pathOfTestApp = __DIR__;
- $pathOfTestApp .= '/../data/';
- $pathOfTestApp .= 'testapp.zip';
-
- $tmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
- \OC_Helper::copyr($pathOfTestApp, $tmp);
-
- $data = array(
- 'path' => $tmp,
- 'source' => 'path',
- 'appdata' => [
- 'id' => 'Bar',
- 'level' => 100,
- ]
+ // Extract app
+ $pathOfTestApp = __DIR__ . '/../data/testapp.zip';
+ $tar = new ZIP($pathOfTestApp);
+ $tar->extract(\OC_App::getInstallPath());
+
+ // Install app
+ $installer = new Installer(
+ \OC::$server->getAppFetcher(),
+ \OC::$server->getHTTPClientService(),
+ \OC::$server->getTempManager(),
+ \OC::$server->getLogger()
);
-
- $installer = new Installer();
- $installer->installApp($data);
+ $installer->installApp(self::$appid);
$isInstalled = Installer::isInstalled(self::$appid);
-
$this->assertTrue($isInstalled);
- }
-
- public function testUpdateApp() {
- $pathOfOldTestApp = __DIR__;
- $pathOfOldTestApp .= '/../data/';
- $pathOfOldTestApp .= 'testapp.zip';
-
- $oldTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
- \OC_Helper::copyr($pathOfOldTestApp, $oldTmp);
-
- $oldData = array(
- 'path' => $oldTmp,
- 'source' => 'path',
- 'appdata' => [
- 'id' => 'Bar',
- 'level' => 100,
- ]
- );
-
- $pathOfNewTestApp = __DIR__;
- $pathOfNewTestApp .= '/../data/';
- $pathOfNewTestApp .= 'testapp2.zip';
-
- $newTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
- \OC_Helper::copyr($pathOfNewTestApp, $newTmp);
-
- $newData = array(
- 'path' => $newTmp,
- 'source' => 'path',
- 'appdata' => [
- 'id' => 'Bar',
- 'level' => 100,
- ]
- );
-
- $installer = new Installer();
- $installer->installApp($oldData);
- $oldVersionNumber = \OC_App::getAppVersion(self::$appid);
-
- Installer::updateApp($newData);
- $newVersionNumber = \OC_App::getAppVersion(self::$appid);
-
- $this->assertNotEquals($oldVersionNumber, $newVersionNumber);
+ $installer->removeApp(self::$appid);
}
}
diff --git a/tests/lib/ServerTest.php b/tests/lib/ServerTest.php
index 3ff8787b91a..02fccee628e 100644
--- a/tests/lib/ServerTest.php
+++ b/tests/lib/ServerTest.php
@@ -23,6 +23,8 @@
*/
namespace Test;
+use OC\App\AppStore\Fetcher\AppFetcher;
+use OC\App\AppStore\Fetcher\CategoryFetcher;
/**
* Class Server
@@ -50,6 +52,7 @@ class ServerTest extends \Test\TestCase {
['AllConfig', '\OCP\IConfig'],
['AppConfig', '\OC\AppConfig'],
['AppConfig', '\OCP\IAppConfig'],
+ ['AppFetcher', AppFetcher::class],
['AppHelper', '\OC\AppHelper'],
['AppHelper', '\OCP\IHelper'],
['AppManager', '\OC\App\AppManager'],
@@ -59,6 +62,7 @@ class ServerTest extends \Test\TestCase {
['AvatarManager', '\OC\AvatarManager'],
['AvatarManager', '\OCP\IAvatarManager'],
+ ['CategoryFetcher', CategoryFetcher::class],
['CapabilitiesManager', '\OC\CapabilitiesManager'],
['ContactsManager', '\OC\ContactsManager'],
['ContactsManager', '\OCP\Contacts\IManager'],