2014-06-04 14:29:41 +00:00
|
|
|
<?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.
|
|
|
|
*/
|
|
|
|
|
2014-11-10 21:59:50 +00:00
|
|
|
class Test_Installer extends \Test\TestCase {
|
2014-06-04 14:29:41 +00:00
|
|
|
|
|
|
|
private static $appid = 'testapp';
|
2014-06-05 14:32:12 +00:00
|
|
|
private $appstore;
|
|
|
|
|
2014-11-10 21:59:50 +00:00
|
|
|
protected function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
2015-12-02 15:11:38 +00:00
|
|
|
$config = \OC::$server->getConfig();
|
|
|
|
$this->appstore = $config->setSystemValue('appstoreenabled', true);
|
|
|
|
$config->setSystemValue('appstoreenabled', true);
|
2014-06-05 14:32:12 +00:00
|
|
|
OC_Installer::removeApp(self::$appid);
|
|
|
|
}
|
|
|
|
|
2014-11-10 21:59:50 +00:00
|
|
|
protected function tearDown() {
|
2014-06-05 14:32:12 +00:00
|
|
|
OC_Installer::removeApp(self::$appid);
|
2015-12-02 15:11:38 +00:00
|
|
|
\OC::$server->getConfig()->setSystemValue('appstoreenabled', $this->appstore);
|
2014-11-10 21:59:50 +00:00
|
|
|
|
|
|
|
parent::tearDown();
|
2014-06-05 14:32:12 +00:00
|
|
|
}
|
2014-06-04 14:29:41 +00:00
|
|
|
|
|
|
|
public function testInstallApp() {
|
|
|
|
$pathOfTestApp = __DIR__;
|
|
|
|
$pathOfTestApp .= '/../data/';
|
|
|
|
$pathOfTestApp .= 'testapp.zip';
|
|
|
|
|
2014-06-05 14:32:12 +00:00
|
|
|
$tmp = OC_Helper::tmpFile('.zip');
|
2014-06-04 14:29:41 +00:00
|
|
|
OC_Helper::copyr($pathOfTestApp, $tmp);
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
'path' => $tmp,
|
|
|
|
'source' => 'path',
|
|
|
|
);
|
|
|
|
|
|
|
|
OC_Installer::installApp($data);
|
|
|
|
$isInstalled = OC_Installer::isInstalled(self::$appid);
|
|
|
|
|
|
|
|
$this->assertTrue($isInstalled);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUpdateApp() {
|
|
|
|
$pathOfOldTestApp = __DIR__;
|
|
|
|
$pathOfOldTestApp .= '/../data/';
|
|
|
|
$pathOfOldTestApp .= 'testapp.zip';
|
|
|
|
|
2014-06-05 14:32:12 +00:00
|
|
|
$oldTmp = OC_Helper::tmpFile('.zip');
|
2014-06-04 14:29:41 +00:00
|
|
|
OC_Helper::copyr($pathOfOldTestApp, $oldTmp);
|
|
|
|
|
|
|
|
$oldData = array(
|
|
|
|
'path' => $oldTmp,
|
|
|
|
'source' => 'path',
|
|
|
|
);
|
|
|
|
|
|
|
|
$pathOfNewTestApp = __DIR__;
|
|
|
|
$pathOfNewTestApp .= '/../data/';
|
|
|
|
$pathOfNewTestApp .= 'testapp2.zip';
|
|
|
|
|
2014-06-05 14:32:12 +00:00
|
|
|
$newTmp = OC_Helper::tmpFile('.zip');
|
2014-06-04 14:29:41 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|