diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/testapp.zip | bin | 0 -> 895 bytes | |||
-rw-r--r-- | tests/data/testapp2.zip | bin | 0 -> 2449 bytes | |||
-rw-r--r-- | tests/lib/installer.php | 74 |
3 files changed, 74 insertions, 0 deletions
diff --git a/tests/data/testapp.zip b/tests/data/testapp.zip Binary files differnew file mode 100644 index 00000000000..e76c0d18724 --- /dev/null +++ b/tests/data/testapp.zip diff --git a/tests/data/testapp2.zip b/tests/data/testapp2.zip Binary files differnew file mode 100644 index 00000000000..f46832f7a75 --- /dev/null +++ b/tests/data/testapp2.zip diff --git a/tests/lib/installer.php b/tests/lib/installer.php new file mode 100644 index 00000000000..97b14ef579a --- /dev/null +++ b/tests/lib/installer.php @@ -0,0 +1,74 @@ +<?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. + */ + +class Test_Installer extends PHPUnit_Framework_TestCase { + + private static $appid = 'testapp'; + + public function testInstallApp() { + $pathOfTestApp = __DIR__; + $pathOfTestApp .= '/../data/'; + $pathOfTestApp .= 'testapp.zip'; + + $tmp = OC_Helper::tmpFile(); + OC_Helper::copyr($pathOfTestApp, $tmp); + + $data = array( + 'path' => $tmp, + 'source' => 'path', + ); + + OC_Installer::installApp($data); + $isInstalled = OC_Installer::isInstalled(self::$appid); + + $this->assertTrue($isInstalled); + + //clean-up + OC_Installer::removeApp(self::$appid); + unlink($tmp); + } + + public function testUpdateApp() { + $pathOfOldTestApp = __DIR__; + $pathOfOldTestApp .= '/../data/'; + $pathOfOldTestApp .= 'testapp.zip'; + + $oldTmp = OC_Helper::tmpFile(); + OC_Helper::copyr($pathOfOldTestApp, $oldTmp); + + $oldData = array( + 'path' => $oldTmp, + 'source' => 'path', + ); + + $pathOfNewTestApp = __DIR__; + $pathOfNewTestApp .= '/../data/'; + $pathOfNewTestApp .= 'testapp2.zip'; + + $newTmp = OC_Helper::tmpFile(); + OC_Helper::copyr($pathOfNewTestApp, $newTmp); + + $newData = array( + 'path' => $newTmp, + 'source' => 'path', + ); + + OC_Installer::installApp($oldData); + $oldVersionNumber = OC_App::getAppVersion(self::$appid); + + OC_Installer::updateApp($newData); + $newVersionNumber = OC_App::getAppVersion(self::$appid); + + $this->assertNotEquals($oldVersionNumber, $newVersionNumber); + + //clean-up + OC_Installer::removeApp(self::$appid); + unlink($oldTmp); + unlink($newTmp); + } +} |