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); }
/** * @param string $app * @return int */ private static function downloadApp($app) { $ocsClient = new OCSClient(\OC::$server->getHTTPClientService(), \OC::$server->getConfig(), \OC::$server->getLogger()); $appData = $ocsClient->getApplication($app, \OCP\Util::getVersion()); $download = $ocsClient->getApplicationDownload($app, \OCP\Util::getVersion()); if (isset($download['downloadlink']) and $download['downloadlink'] != '') { // Replace spaces in download link without encoding entire URL $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']); $info = array('source' => 'http', 'href' => $download['downloadlink'], 'appdata' => $appData); $app = Installer::installApp($info); } return $app; }