コード例 #1
0
 function testIsInstallerStepCompleted()
 {
     $oStorage = OX_Admin_UI_Install_InstallUtils::getSessionStorage();
     $oStatus = $oStorage->set('installStatus', null);
     $aTask = array('name' => 'test', 'type' => 'testtype');
     $result = OX_Upgrade_Util_Job::isInstallerStepCompleted('database', $aTask);
     $this->assertFalse($result);
     $this->assertEqual($aTask['errors'], array('Installation process not detected'));
     unset($aTask['errors']);
     Mock::generatePartial('OX_Admin_UI_Install_InstallStatus', 'OX_Admin_UI_Install_InstallStatusMock', array('isInstall', 'isUpgrade'));
     $oInstallStatus = new OX_Admin_UI_Install_InstallStatusMock($this);
     $oInstallStatus->setReturnValue('isInstall', true);
     $oInstallStatus->setReturnValue('isUpgrade', false);
     $oStatus = $oStorage->set('installStatus', $oInstallStatus);
     $result = OX_Upgrade_Util_Job::isInstallerStepCompleted('database', $aTask);
     $this->assertFalse($result);
     $this->assertEqual($aTask['errors'], array('Invalid installation step detected'));
     unset($aTask['errors']);
     $oWizard = new OX_Admin_UI_Install_Wizard($oInstallStatus);
     $oWizard->markStepAsCompleted('database');
     $result = OX_Upgrade_Util_Job::isInstallerStepCompleted('database', $aTask);
     $this->assertTrue($result);
     $this->assertTrue(empty($aTask['errors']));
     $oWizard->reset();
     $oStatus = $oStorage->set('installStatus', null);
 }
コード例 #2
0
ファイル: Job.php プロジェクト: Spark-Eleven/revive-adserver
 /**
  * Check if it's install process and given step is completed
  *
  * @param string $step
  * @param string $result result array (should contains name, type, status and errors fields)
  * @return bool
  */
 public static function isInstallerStepCompleted($step, &$result)
 {
     $oStorage = OX_Admin_UI_Install_InstallUtils::getSessionStorage();
     $oStatus = $oStorage->get('installStatus');
     if (!isset($oStatus) || !$oStatus->isInstall() && !$oStatus->isUpgrade()) {
         self::logError($result, 'Installation process not detected');
         return false;
     } else {
         $oWizard = new OX_Admin_UI_Install_Wizard($oStatus);
         if (!$oWizard->isStepCompleted($step)) {
             self::logError($result, 'Invalid installation step detected');
             return false;
         }
     }
     return true;
 }
コード例 #3
0
 /**
  * Attempts to set the given step as current. Before doing that, checks
  * if current step  can be reached, ie.
  * - if it is a valid wizard step
  * - if all previous steps have been marked as reached.
  *
  * If step is not a valid step it will redirect to first wizard step.
  *
  * If step is valid, but is not reachable yet, it will redirect to
  * first unreached step.
  *
  * @param OX_Admin_UI_Install_Wizard $oWizard
  */
 protected function setCurrentStepIfReachable($oWizard, $stepId)
 {
     //check if given step is valid, if not, direct user to index
     if (!$oWizard->isStep($stepId)) {
         $this->redirect($oWizard->getFirstStep());
     }
     $oWizard->setCurrentStep($stepId);
     $reachable = $oWizard->checkStepReachable();
     //reachable is fine, check if not secured
     if ($reachable) {
         $aMeta = $oWizard->getStepMeta();
         if ($aMeta['secured'] == true && !OA_Upgrade_Login::checkLogin()) {
             $this->redirect('login');
         }
         return true;
     } else {
         //if step is not reachable check the last one marked as completed
         //and redirect user to the next one
         $lastCompleted = $oWizard->getLastCompletedStep();
         if ($lastCompleted != null) {
             $forwardStep = $oWizard->getNextStep($lastCompleted);
         }
         if ($forwardStep == null) {
             $forwardStep = $oWizard->getFirstStep();
         }
         $this->redirect($forwardStep);
     }
 }