summaryrefslogtreecommitdiffstats
path: root/tests/lib/InstallerTest.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-28 15:15:34 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-05-02 08:52:06 +0200
commite049953d1af24feeb57796ac4025f0f607ac1cdf (patch)
tree7b599af5deab65048396c6b17ed8f24b10f43f86 /tests/lib/InstallerTest.php
parent54f45f95f51dc14d6a7126170b3277a3ad57b608 (diff)
downloadnextcloud-server-e049953d1af24feeb57796ac4025f0f607ac1cdf.tar.gz
nextcloud-server-e049953d1af24feeb57796ac4025f0f607ac1cdf.zip
OC_Installer -> \OC\Installer
Diffstat (limited to 'tests/lib/InstallerTest.php')
-rw-r--r--tests/lib/InstallerTest.php99
1 files changed, 99 insertions, 0 deletions
diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php
new file mode 100644
index 00000000000..e1c17b841a2
--- /dev/null
+++ b/tests/lib/InstallerTest.php
@@ -0,0 +1,99 @@
+<?php
+/**
+ * Copyright (c) 2014 Georg Ehrke <georg@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test;
+
+
+use OC\Installer;
+
+class InstallerTest extends TestCase {
+
+ private static $appid = 'testapp';
+ private $appstore;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $config = \OC::$server->getConfig();
+ $this->appstore = $config->setSystemValue('appstoreenabled', true);
+ $config->setSystemValue('appstoreenabled', true);
+ Installer::removeApp(self::$appid);
+ }
+
+ protected function tearDown() {
+ 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,
+ ]
+ );
+
+ Installer::installApp($data);
+ $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::installApp($oldData);
+ $oldVersionNumber = \OC_App::getAppVersion(self::$appid);
+
+ Installer::updateApp($newData);
+ $newVersionNumber = \OC_App::getAppVersion(self::$appid);
+
+ $this->assertNotEquals($oldVersionNumber, $newVersionNumber);
+ }
+}