function testgetTasksUrls() { Mock::generatePartial('OA_Upgrade', 'OA_UpgradeMock', array('getPostUpgradeTasks')); $baseInstallUrl = 'my base url'; $oUpgrade = new OA_UpgradeMock($this); $oUpgrade->setReturnValue('getPostUpgradeTasks', array('task_1', 'task_2')); $GLOBALS['strPostInstallTaskRunning'] = 'Running task'; $result = OX_Upgrade_PostUpgradeTask_Controller::getTasksUrls($baseInstallUrl, $oUpgrade); $expected = array(array('id' => 'task:task_1', 'name' => 'Running task: task_1', 'url' => $baseInstallUrl . 'install-runtask.php?task=task_1'), array('id' => 'task:task_2', 'name' => 'Running task: task_2', 'url' => $baseInstallUrl . 'install-runtask.php?task=task_2')); $this->assertEqual($result, $expected); }
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); }