public function testUpdate() { $upgrade_controller = new UpgradeApplicationController(true); $valid_url = AppUpgraderClient::$UPDATE_URL; error_reporting(E_ERROR | E_USER_ERROR); // turn off warning messages $config = Config::getInstance(); $proper_version = $config->getValue('THINKUP_VERSION'); $config->setValue('THINKUP_VERSION', 1.0); //set a low version num // delete index.pho $this->assertTrue(unlink($this->test_web_dir . '/index.php')); // create a file in out data dir touch($this->test_web_dir . '/data/dont_delete_me'); AppUpgraderClient::$UPDATE_URL = $this->test_web_dir . '/data/valid_json'; file_put_contents(AppUpgraderClient::$UPDATE_URL, '{"version":"100.1", "url":"' . THINKUP_WEBAPP_PATH . 'test_installer/thinkup.zip"}'); $update_info = $upgrade_controller->runUpdate($this->test_web_dir); $this->assertPattern('/data\\/\\d+\\-v1\\-config\\.inc\\.backup\\.php/', $update_info['config']); $this->assertPattern('/data\\/\\d+\\-v1\\-backup\\.zip/', $update_info['backup']); $this->assertTrue(file_exists($this->test_web_dir . '/index.php'), "we should have our index file back"); $data_path = FileDataManager::getDataPath(); $this->assertFalse(is_dir($data_path . '/data/thinkup'), "our unzipped update deleted"); $this->assertTrue(file_exists($this->test_web_dir . '/data/dont_delete_me'), "/data/* not deleted"); unlink(AppUpgraderClient::$UPDATE_URL); // reset AppUpgraderClient::$UPDATE_URL = $valid_url; error_reporting(E_STRICT); // reset error reporting $config->setValue('THINKUP_VERSION', $proper_version); }
/** * * ThinkUp/webapp/install/upgrade-application.php * * Copyright (c) 2012-2013 Mark Wilkie * * LICENSE: * * This file is part of ThinkUp (http://thinkup.com). * * ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any * later version. * * ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with ThinkUp. If not, see * <http://www.gnu.org/licenses/>. * * * @license http://www.gnu.org/licenses/gpl.html * @copyright 2012-2013 Mark Wilkie * @author Mark Wilkie <mwilkie[at]gmail[dot]com> * */ chdir(".."); require_once 'init.php'; $controller = new UpgradeApplicationController(); echo $controller->go();