mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°9144 Fix unit tests
This commit is contained in:
@@ -38,7 +38,7 @@ class ModelReflectionSerializer
|
||||
$sOutput = "";
|
||||
$iRes = 0;
|
||||
|
||||
$sCommandLine = sprintf("$sPHPExec %s/get_model_reflection.php --env='%s'", __DIR__, $sEnv);
|
||||
$sCommandLine = sprintf("$sPHPExec %s/get_model_reflection.php --env=%s", __DIR__, $sEnv);
|
||||
exec($sCommandLine, $sOutput, $iRes);
|
||||
if ($iRes != 0) {
|
||||
$this->LogErrorWithProperLogger("Cannot get classes", null, ['env' => $sEnv, 'code' => $iRes, "output" => $sOutput]);
|
||||
|
||||
@@ -29,21 +29,8 @@ class SetupAudit extends AbstractSetupAudit
|
||||
return;
|
||||
}
|
||||
|
||||
$sCurrentEnv = MetaModel::GetEnvironment();
|
||||
|
||||
$sConfFile = utils::GetConfigFilePath($sCurrentEnv);
|
||||
MetaModel::Startup($sConfFile, false /* $bModelOnly */, false /* $bAllowCache */, false /* $bTraceSourceFiles */, $sCurrentEnv);
|
||||
if ($sCurrentEnv === $this->sEnvBefore) {
|
||||
$this->aClassesBefore = MetaModel::GetClasses();
|
||||
} else {
|
||||
$this->aClassesBefore = ModelReflectionSerializer::GetInstance()->GetModelFromEnvironment($this->sEnvBefore);
|
||||
}
|
||||
|
||||
if ($sCurrentEnv === $this->sEnvAfter) {
|
||||
$this->aClassesAfter = MetaModel::GetClasses();
|
||||
} else {
|
||||
$this->aClassesAfter = ModelReflectionSerializer::GetInstance()->GetModelFromEnvironment($this->sEnvAfter);
|
||||
}
|
||||
$this->aClassesBefore = ModelReflectionSerializer::GetInstance()->GetModelFromEnvironment($this->sEnvBefore);
|
||||
$this->aClassesAfter = ModelReflectionSerializer::GetInstance()->GetModelFromEnvironment($this->sEnvAfter);
|
||||
|
||||
$this->bClassesInitialized = true;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ require_once(APPROOT.'application/application.inc.php');
|
||||
$sEnv = null;
|
||||
if (isset($argv)) {
|
||||
foreach ($argv as $iArg => $sArg) {
|
||||
if (preg_match('/^--env=\'(.*)\'$/', $sArg, $aMatches)) {
|
||||
if (preg_match('/^--env=(.*)$/', $sArg, $aMatches)) {
|
||||
$sEnv = $aMatches[1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ class WizardController
|
||||
$this->PushStep(['class' => $sCurrentStepClass, 'state' => $sCurrentState]);
|
||||
}
|
||||
$aPossibleSteps = $oStep->GetPossibleSteps();
|
||||
$aNextStepInfo = $oStep->ProcessParams(true); // true => moving forward
|
||||
$aNextStepInfo = $oStep->UpdateWizardStateAndGetNextStep(true); // true => moving forward
|
||||
if (in_array($aNextStepInfo['class'], $aPossibleSteps)) {
|
||||
$oNextStep = new $aNextStepInfo['class']($this, $aNextStepInfo['state']);
|
||||
$this->DisplayStep($oNextStep);
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2026 Combodo SAS
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
abstract class AbstractWizStepInstall extends WizardStep
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ class WizStepAdminAccount extends WizardStep
|
||||
return [WizStepInstallMiscParams::class];
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
$this->oWizard->SaveParameter('admin_user', '');
|
||||
$this->oWizard->SaveParameter('admin_pwd', '');
|
||||
|
||||
@@ -35,7 +35,7 @@ class WizStepDBParams extends WizardStep
|
||||
return ['WizStepAdminAccount'];
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
$this->oWizard->SaveParameter('db_server', '');
|
||||
$this->oWizard->SaveParameter('db_user', '');
|
||||
|
||||
@@ -52,7 +52,7 @@ class WizStepDataAudit extends WizStepInstall
|
||||
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
return ['class' => 'WizStepSummary', 'state' => ''];
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class WizStepDetectedInfo extends WizardStep
|
||||
return ['WizStepUpgradeMiscParams', 'WizStepLicense2'];
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
$sUpgradeType = utils::ReadParam('upgrade_type');
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class WizStepDone extends WizardStep
|
||||
return [];
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
return ['class' => '', 'state' => ''];
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class WizStepInstall extends AbstractWizStepInstall
|
||||
}
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
return ['class' => 'WizStepDone', 'state' => ''];
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class WizStepInstallMiscParams extends AbstractWizStepMiscParams
|
||||
return ['WizStepModulesChoice'];
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
$this->oWizard->SaveParameter('default_language', '');
|
||||
$this->oWizard->SaveParameter('application_url', '');
|
||||
|
||||
@@ -34,7 +34,7 @@ class WizStepInstallOrUpgrade extends WizardStep
|
||||
return ['WizStepDetectedInfo', 'WizStepLicense'];
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
$sNextStep = '';
|
||||
$sInstallMode = utils::ReadParam('install_mode');
|
||||
|
||||
@@ -35,7 +35,7 @@ class WizStepLicense extends WizardStep
|
||||
return ['WizStepDBParams'];
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
$this->oWizard->SaveParameter('accept_license', 'no');
|
||||
return ['class' => 'WizStepDBParams', 'state' => ''];
|
||||
|
||||
@@ -28,7 +28,7 @@ class WizStepLicense2 extends WizStepLicense
|
||||
return ['WizStepUpgradeMiscParams'];
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
return ['class' => 'WizStepUpgradeMiscParams', 'state' => ''];
|
||||
}
|
||||
|
||||
@@ -118,7 +118,17 @@ class WizStepModulesChoice extends WizardStep
|
||||
return [$aExtensionsAdded, $aExtensionsRemoved, $aExtensionsNotUninstallable];
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function IsDataAuditEnabled(): bool {
|
||||
$sPath = APPROOT.'env-production';
|
||||
if (!is_dir($sPath)) {
|
||||
SetupLog::Info("Reinstallation of an iTop from a backup (No env-production found). Setup data audit disabled");
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
// Accumulates the selected modules:
|
||||
$index = $this->GetStepIndex();
|
||||
@@ -156,7 +166,7 @@ class WizStepModulesChoice extends WizardStep
|
||||
$this->oWizard->SetParameter('removed_extensions', json_encode($aExtensionsRemoved));
|
||||
$this->oWizard->SetParameter('extensions_not_uninstallable', json_encode(array_keys($aExtensionsNotUninstallable)));
|
||||
$sMode = $this->oWizard->GetParameter('mode', 'install');
|
||||
if ($sMode == 'install') {
|
||||
if ($sMode == 'install' || !$this->IsDataAuditEnabled()) {
|
||||
return ['class' => 'WizStepSummary', 'state' => ''];
|
||||
} else {
|
||||
return ['class' => 'WizStepDataAudit', 'state' => ''];
|
||||
@@ -824,7 +834,7 @@ EOF
|
||||
return 'Non-uninstallable extension missing';
|
||||
}
|
||||
|
||||
if ($this->GetStepInfo(1 + $this->GetStepIndex()) === null) {
|
||||
if ($this->GetStepInfo(1 + $this->GetStepIndex()) === null && $this->IsDataAuditEnabled()) {
|
||||
return 'Check compatibility';
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class WizStepSummary extends AbstractWizStepInstall
|
||||
}
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
$this->oWizard->SaveParameter('db_backup', false);
|
||||
$this->oWizard->SaveParameter('db_backup_path', '');
|
||||
|
||||
@@ -34,7 +34,7 @@ class WizStepUpgradeMiscParams extends AbstractWizStepMiscParams
|
||||
return ['WizStepModulesChoice'];
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
$this->oWizard->SaveParameter('application_url', '');
|
||||
$this->oWizard->SaveParameter('graphviz_path', '');
|
||||
|
||||
@@ -46,7 +46,7 @@ class WizStepWelcome extends WizardStep
|
||||
return ['WizStepInstallOrUpgrade'];
|
||||
}
|
||||
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true)
|
||||
{
|
||||
$sUID = SetupUtils::CreateSetupToken();
|
||||
$this->oWizard->SetParameter('authent', $sUID);
|
||||
|
||||
@@ -106,7 +106,7 @@ abstract class WizardStep
|
||||
* @param bool $bMoveForward True if the wizard is moving forward 'Next >>' button pressed, false otherwise
|
||||
* @return hash array('class' => $sNextClass, 'state' => $sNextState)
|
||||
*/
|
||||
abstract public function ProcessParams($bMoveForward = true);
|
||||
abstract public function UpdateWizardStateAndGetNextStep($bMoveForward = true);
|
||||
|
||||
/**
|
||||
* Returns the list of possible steps from this step forward
|
||||
|
||||
Reference in New Issue
Block a user