diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-10-31 11:07:54 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-10-31 17:17:47 +0100 |
commit | 8acb54aa0b32a8b750f8ab3aba9f63aa931be7d1 (patch) | |
tree | af744fe68adce931a8bb1b5918c93210b828124e /tests/lib/InstallerTest.php | |
parent | df7fd2b57cb211b3a6a9febdca4ab0a21baed19d (diff) | |
download | nextcloud-server-8acb54aa0b32a8b750f8ab3aba9f63aa931be7d1.tar.gz nextcloud-server-8acb54aa0b32a8b750f8ab3aba9f63aa931be7d1.zip |
Add update support
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'tests/lib/InstallerTest.php')
-rw-r--r-- | tests/lib/InstallerTest.php | 91 |
1 files changed, 28 insertions, 63 deletions
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); } } |