mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-17 06:18:44 +02:00
N°9144 - fix broken fresh install
This commit is contained in:
@@ -84,7 +84,7 @@ class ApplicationInstallSequencer extends StepSequencer
|
||||
$sDestination = $aBackupOptions['destination'];
|
||||
$sSourceConfigFile = $aBackupOptions['configuration_file'];
|
||||
$sMySQLBinDir = $this->oParams->Get('mysql_bindir', null);
|
||||
$this->oRunTimeEnvironment->Backup($this->oConfig, $sDestination, $sSourceConfigFile, $sMySQLBinDir);
|
||||
$this->oRunTimeEnvironment->Backup($this->GetConfig(), $sDestination, $sSourceConfigFile, $sMySQLBinDir);
|
||||
}
|
||||
|
||||
return $this->ComputeNextStep($sStep);
|
||||
@@ -176,8 +176,6 @@ class ApplicationInstallSequencer extends StepSequencer
|
||||
|
||||
$this->oRunTimeEnvironment->UpdateDBSchema($oConfig, $sMode, $aSelectedModules);
|
||||
|
||||
$oConfig->Set('access_mode', ACCESS_FULL);
|
||||
|
||||
$this->oRunTimeEnvironment->SetDbUUID();
|
||||
|
||||
SetupLog::Info("Database Schema Successfully Updated for environment '$sTargetEnvironment'.");
|
||||
|
||||
@@ -25,7 +25,7 @@ abstract class StepSequencer
|
||||
public const INFO = 4;
|
||||
protected array $aStepsHistory = [];
|
||||
protected Parameters $oParams;
|
||||
protected Config $oConfig;
|
||||
protected ?Config $oTestConfig = null;
|
||||
protected RunTimeEnvironment $oRunTimeEnvironment;
|
||||
protected string $sSourceDesc;
|
||||
|
||||
@@ -46,11 +46,7 @@ abstract class StepSequencer
|
||||
}
|
||||
|
||||
$this->oParams = $oParams;
|
||||
|
||||
$aParamValues = $oParams->GetParamForConfigArray();
|
||||
$this->oConfig = new Config();
|
||||
$this->oConfig->UpdateFromParams($aParamValues);
|
||||
utils::SetConfig($this->oConfig);
|
||||
utils::SetConfig($this->GetConfig());
|
||||
$this->sSourceDesc = $sSourceDesc;
|
||||
}
|
||||
|
||||
@@ -165,24 +161,30 @@ abstract class StepSequencer
|
||||
|
||||
protected function GetConfig()
|
||||
{
|
||||
if (! is_null($this->oTestConfig)) {
|
||||
return $this->oTestConfig;
|
||||
}
|
||||
|
||||
// Caching config here is a bad idea, the first config loaded does not contain module settings
|
||||
$sTargetEnvironment = $this->oRunTimeEnvironment->GetBuildEnv();
|
||||
$sConfigFile = APPCONF.$sTargetEnvironment.'/'.ITOP_CONFIG_FILE;
|
||||
try {
|
||||
if (file_exists($sConfigFile)) {
|
||||
$this->oConfig = new Config($sConfigFile);
|
||||
$oConfig = new Config($sConfigFile);
|
||||
} else {
|
||||
$this->oConfig = new Config();
|
||||
$oConfig = new Config();
|
||||
}
|
||||
|
||||
$oConfig->Set('access_mode', ACCESS_FULL);
|
||||
} catch (Exception $e) {
|
||||
SetupLog::Exception("Setup error", $e);
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$aParamValues = $this->oParams->GetParamForConfigArray();
|
||||
$this->oConfig->UpdateFromParams($aParamValues);
|
||||
$oConfig->UpdateFromParams($aParamValues);
|
||||
|
||||
return $this->oConfig;
|
||||
return $oConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,6 @@ abstract class AbstractWizStepInstall extends WizardStep
|
||||
}
|
||||
|
||||
$sSourceDir = $this->oWizard->GetParameter('source_dir');
|
||||
$aCopies = [];
|
||||
if (($sMode == 'upgrade') && ($this->oWizard->GetParameter('upgrade_type') == 'keep-previous')) {
|
||||
$sPreviousVersionDir = $this->oWizard->GetParameter('previous_version_dir');
|
||||
//$aCopies[] = ['source' => $sSourceDir, 'destination' => 'modules']; // Source is an absolute path, destination is relative to APPROOT
|
||||
|
||||
@@ -11,6 +11,7 @@ use RunTimeEnvironment;
|
||||
class ApplicationInstallerSequencerTest extends ItopTestCase
|
||||
{
|
||||
private \RunTimeEnvironment&\PHPUnit\Framework\MockObject\MockObject $oRunTimeEnvironment;
|
||||
private \Config&\PHPUnit\Framework\MockObject\MockObject $oConfig;
|
||||
private ApplicationInstallSequencer $oSequencer;
|
||||
|
||||
protected function setUp(): void
|
||||
@@ -24,9 +25,6 @@ class ApplicationInstallerSequencerTest extends ItopTestCase
|
||||
$this->RequireOnceItopFile('/setup/parameters.class.inc.php');
|
||||
$this->RequireOnceItopFile('/setup/setuputils.class.inc.php');
|
||||
$this->RequireOnceItopFile('/setup/runtimeenv.class.inc.php');
|
||||
|
||||
// Copy conf to production-test
|
||||
\SetupUtils::copydir(APPROOT.'conf/production', APPROOT.'conf/production-test');
|
||||
}
|
||||
|
||||
public static function FirstStepProvider()
|
||||
@@ -141,7 +139,8 @@ class ApplicationInstallerSequencerTest extends ItopTestCase
|
||||
];
|
||||
|
||||
$this->GivenApplicationInstallSequencer($aAdditionalParams);
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('Backup');
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('Backup')
|
||||
->with($this->oConfig, '/my_backup_file_path', '/my_config_file_path', null);
|
||||
|
||||
$aRes = $this->oSequencer->ExecuteStep('backup');
|
||||
$aExpected = [
|
||||
@@ -163,7 +162,8 @@ class ApplicationInstallerSequencerTest extends ItopTestCase
|
||||
];
|
||||
$this->GivenApplicationInstallSequencer($aAdditionalParams);
|
||||
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('MigrateDataBeforeUpdateStructure');
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('MigrateDataBeforeUpdateStructure')
|
||||
->with('install', $this->oConfig);
|
||||
|
||||
$aRes = $this->oSequencer->ExecuteStep('migrate-before');
|
||||
$aExpected = [
|
||||
@@ -207,7 +207,8 @@ class ApplicationInstallerSequencerTest extends ItopTestCase
|
||||
];
|
||||
$this->GivenApplicationInstallSequencer($aAdditionalParams);
|
||||
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('UpdateDBSchema');
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('UpdateDBSchema')
|
||||
->with($this->oConfig, 'install', ["a" => "b"]);
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('SetDbUUID')
|
||||
->with();
|
||||
|
||||
@@ -231,7 +232,8 @@ class ApplicationInstallerSequencerTest extends ItopTestCase
|
||||
];
|
||||
$this->GivenApplicationInstallSequencer($aAdditionalParams);
|
||||
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('MigrateDataAfterUpdateStructure');
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('MigrateDataAfterUpdateStructure')
|
||||
->with('install', $this->oConfig);
|
||||
|
||||
$aRes = $this->oSequencer->ExecuteStep('migrate-after');
|
||||
$aExpected = [
|
||||
@@ -257,7 +259,8 @@ class ApplicationInstallerSequencerTest extends ItopTestCase
|
||||
];
|
||||
$this->GivenApplicationInstallSequencer($aAdditionalParams);
|
||||
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('AfterDBCreate');
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('AfterDBCreate')
|
||||
->with($this->oConfig, 'install', ["a" => "b"], $aAdminParams);
|
||||
|
||||
$aRes = $this->oSequencer->ExecuteStep('after-db-create');
|
||||
$aExpected = [
|
||||
@@ -278,7 +281,8 @@ class ApplicationInstallerSequencerTest extends ItopTestCase
|
||||
];
|
||||
$this->GivenApplicationInstallSequencer($aAdditionalParams);
|
||||
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('DoLoadData');
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('DoLoadData')
|
||||
->with($this->oConfig, true, ["a" => "b"]);
|
||||
|
||||
$aRes = $this->oSequencer->ExecuteStep('load-data');
|
||||
$aExpected = [
|
||||
@@ -300,7 +304,8 @@ class ApplicationInstallerSequencerTest extends ItopTestCase
|
||||
'sample_data' => 1,
|
||||
];
|
||||
$this->GivenApplicationInstallSequencer($aAdditionalParams);
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('DoCreateConfig');
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('DoCreateConfig')
|
||||
->with($this->oConfig, "6.6.6", ["a" => "b"], ["c" => "d"], null);
|
||||
|
||||
$aRes = $this->oSequencer->ExecuteStep('create-config');
|
||||
$aExpected = [
|
||||
@@ -333,7 +338,7 @@ class ApplicationInstallerSequencerTest extends ItopTestCase
|
||||
public function testAnyFailure()
|
||||
{
|
||||
$this->GivenApplicationInstallSequencer();
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('UpdateDBSchema')
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('GetBuildEnv')
|
||||
->willThrowException(new \CoreException('SHADOK MSG'));
|
||||
|
||||
$aRes = $this->oSequencer->ExecuteStep('db-schema');
|
||||
@@ -483,14 +488,21 @@ class ApplicationInstallerSequencerTest extends ItopTestCase
|
||||
{
|
||||
$this->oRunTimeEnvironment = $this->createMock(RunTimeEnvironment::class);
|
||||
if (! $bStepComputationOnly) {
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('EnterReadOnlyMode');
|
||||
$this->oRunTimeEnvironment->expects($this->any())->method('GetBuildEnv')->willReturn('production-test');
|
||||
$this->oRunTimeEnvironment->expects($this->once())->method('EnterReadOnlyMode')
|
||||
->with($this->oConfig);
|
||||
}
|
||||
}
|
||||
|
||||
private function GivenConfig(): void
|
||||
{
|
||||
$this->oConfig = $this->createMock(Config::class);
|
||||
}
|
||||
|
||||
private function GivenApplicationInstallSequencer(array $aAdditionalParams = [], bool $bStepComputationOnly = false): void
|
||||
{
|
||||
$this->GivenConfig();
|
||||
$this->GivenRunTimeEnvironment($bStepComputationOnly);
|
||||
$this->oSequencer = new ApplicationInstallSequencer($this->GivenParams($aAdditionalParams), $this->oRunTimeEnvironment);
|
||||
$this->SetNonPublicProperty($this->oSequencer, 'oTestConfig', $this->oConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ class DataAuditSequencerTest extends ItopTestCase
|
||||
public function testDataAuditFirstStep()
|
||||
{
|
||||
$oRunTimeEnvironment = $this->createMock(\RunTimeEnvironment::class);
|
||||
$oRunTimeEnvironment->expects($this->never())->method($this->anything());
|
||||
$oRunTimeEnvironment->expects($this->once())->method('GetBuildEnv')
|
||||
->willReturn('production-test');
|
||||
$oSequencer = new DataAuditSequencer($this->GivenParams(), $oRunTimeEnvironment);
|
||||
|
||||
$aRes = $oSequencer->ExecuteStep();
|
||||
@@ -41,7 +42,8 @@ class DataAuditSequencerTest extends ItopTestCase
|
||||
public function testDataUnknownStep()
|
||||
{
|
||||
$oRunTimeEnvironment = $this->createMock(\RunTimeEnvironment::class);
|
||||
$oRunTimeEnvironment->expects($this->never())->method($this->anything());
|
||||
$oRunTimeEnvironment->expects($this->once())->method('GetBuildEnv')
|
||||
->willReturn('production-test');
|
||||
$oSequencer = new DataAuditSequencer($this->GivenParams(), $oRunTimeEnvironment);
|
||||
|
||||
$aRes = $oSequencer->ExecuteStep('gabuzomeu');
|
||||
|
||||
Reference in New Issue
Block a user