function testgetTasksUrls() { // Mock install status to mark update process Mock::generatePartial('OX_Admin_UI_Install_InstallStatus', 'OX_Admin_UI_Install_InstallStatusMock', array('isUpgrade')); $oInstallStatus = new OX_Admin_UI_Install_InstallStatusMock($this); $oInstallStatus->setReturnValue('isUpgrade', true); $oStorage = OX_Admin_UI_Install_InstallUtils::getSessionStorage(); @($oStatus = $oStorage->set('installStatus', $oInstallStatus)); include MAX_PATH . '/etc/default_plugins.php'; // set default plugins as installed except last one foreach ($aDefaultPlugins as $idx => $aPlugin) { $GLOBALS['_MAX']['CONF']['plugins'][$aPlugin['name']] = true; $lastPlugin = $aPlugin['name']; $lastPluginData = $aPlugin; } unset($GLOBALS['_MAX']['CONF']['plugins'][$lastPlugin]); $baseInstallUrl = 'my base url'; $GLOBALS['strPluginTaskChecking'] = 'Checking'; $GLOBALS['strPluginTaskInstalling'] = 'Installing'; $aExpected = array(); foreach ($GLOBALS['_MAX']['CONF']['plugins'] as $pluginName => $pluginEnabled) { $aExpected[] = array('id' => 'plugin:' . $pluginName, 'name' => $GLOBALS['strPluginTaskChecking'] . ': <br/> ' . $this->_correctPluginName($pluginName), 'url' => $baseInstallUrl . 'install-plugin.php?status=1&plugin=' . $pluginName); } $aExpected[] = array('id' => 'plugin:' . $lastPlugin, 'name' => $GLOBALS['strPluginTaskInstalling'] . ': <br/> ' . $this->_correctPluginName($lastPlugin), 'url' => $baseInstallUrl . 'install-plugin.php?status=0&plugin=' . $lastPlugin . (empty($lastPluginData['disabled']) ? '' : '&disabled=1')); $result = OX_Upgrade_InstallPlugin_Controller::getTasksUrls($baseInstallUrl); $this->assertEqual($result, $aExpected); $oStatus = $oStorage->set('installStatus', null); }
public function jobsAction() { $oWizard = new OX_Admin_UI_Install_Wizard($this->getInstallStatus()); if ($oWizard->isStep('configuration')) { //this will be visible under config wizard entry $current = 'configuration'; } else { $current = 'database'; } $this->setCurrentStepIfReachable($oWizard, $current); $oUpgrader = $this->getUpgrader(); $isUpgrade = $this->getInstallStatus()->isUpgrade(); $oRequest = $this->getRequest(); $oStorage = OX_Admin_UI_Install_InstallUtils::getSessionStorage(); if ($oRequest->isGet()) { $oStorage->set('aJobStatuses', null); } if ($oRequest->isPost()) { $aJobErrors = $oRequest->getParam('jobError'); //check if there were any PHP errors when executing jobs //these are kind of errros which task and plugin runners might be //unable to catch and report in session eg. fatal error, timeout etc. if (!empty($aJobErrors)) { //push any errors through session so they can be presented in next step $aJobStatuses = $oStorage->get('aJobStatuses'); foreach ($aJobErrors as $id => $errMessage) { $aJobStatuses[$id]['errors'][] = $errMessage; list($type, $name) = explode(':', $id); $aJobStatuses[$id]['name'] = $name; $aJobStatuses[$id]['type'] = $type; } $oStorage->set('aJobStatuses', $aJobStatuses); } $this->redirect($oWizard->getNextStep()); } // Perform auto-login at this stage, so that the install-plugin can verify if ($this->getInstallStatus()->isInstall()) { OA_Upgrade_Login::autoLogin(); } // Use current url as base path for calling install-plugin $baseInstallUrl = $this->getRequest()->getBaseUrl(); //collect tasks $aUrls = OX_Upgrade_InstallPlugin_Controller::getTasksUrls($baseInstallUrl); $aUrls = array_merge($aUrls, OX_Upgrade_PostUpgradeTask_Controller::getTasksUrls($baseInstallUrl, $oUpgrader)); $json = new Services_JSON(); $jsonJobs = $json->encode($aUrls); $this->setModelProperty('oWizard', $oWizard); $this->setModelProperty('isUpgrade', $isUpgrade); $this->setModelProperty('jobs', $jsonJobs); }