review: rework InstallationChoicesToModuleConverter

This commit is contained in:
odain
2026-02-04 14:59:09 +01:00
parent 67013df7e7
commit f8072f6422
2 changed files with 442 additions and 191 deletions

View File

@@ -51,12 +51,11 @@ class InstallationChoicesToModuleConverter
if (!is_array($aSteps)) {
return [];
}
$aInstalledModuleNames = $this->FindInstalledPackageModules($aPackageModules, $aInstallationChoices, $aSteps);
} else {
$aSteps = $aInstallationChoices;
$aInstalledModuleNames = $this->FindInstalledPackageModules($aPackageModules, $aInstallationChoices);
}
$aInstalledModuleNames = $this->FindInstalledPackageModules($aPackageModules, $aInstallationChoices, $aSteps, $bInstallationFileProvided);
$aInstalledModules = [];
foreach (array_keys($aPackageModules) as $sModuleId) {
list($sModuleName) = ModuleDiscovery::GetModuleName($sModuleId);
@@ -68,16 +67,19 @@ class InstallationChoicesToModuleConverter
return $aInstalledModules;
}
private function FindInstalledPackageModules(array $aPackageModules, array $aInstallationChoices, array $aInstallationDescription, bool $bInstallationFileProvided): array
private function FindInstalledPackageModules(array $aPackageModules, array $aInstallationChoices, array $aInstallationDescription = null): array
{
$aInstalledModules = [];
$this->ProcessDefaultModules($aPackageModules, $aInstalledModules);
if ($bInstallationFileProvided) {
$this->ProcessInstallationChoices(array_keys($aInstallationChoices), $aInstallationDescription, $aInstalledModules);
if (is_null($aInstallationDescription)) {
//in legacy usecase: choices are flat modules list already
foreach ($aInstallationChoices as $sModuleName) {
$aInstalledModules[$sModuleName] = true;
}
} else {
$aInstalledModules = array_merge($aInstalledModules, $aInstallationChoices);
$this->ProcessInstallationChoices($aInstallationChoices, $aInstallationDescription, $aInstalledModules);
}
$this->ProcessAutoSelectModules($aPackageModules, $aInstalledModules);
@@ -85,41 +87,65 @@ class InstallationChoicesToModuleConverter
return array_keys($aInstalledModules);
}
private function ProcessDefaultModules(array $aPackageModules, array &$aInstalledModules): void
private function IsDefaultModule(string $sModuleId, array $aModule): bool
{
if (($sModuleId === ROOT_MODULE)) {
return false;
}
if (isset($aModule['auto_select'])) {
return false;
}
if ($aModule['category'] === 'authentication') {
return true;
}
return !$aModule['visible'];
}
private function ProcessDefaultModules(array &$aPackageModules, array &$aInstalledModules): void
{
foreach ($aPackageModules as $sModuleId => $aModule) {
if (($sModuleId != ROOT_MODULE)) {
if (isset($aModule['auto_select'])) {
continue;
}
if (($aModule['category'] == 'authentication') || (!$aModule['visible'])) {
list($sModuleName) = ModuleDiscovery::GetModuleName($sModuleId);
$aInstalledModules[$sModuleName] = true;
}
if ($this->IsDefaultModule($sModuleId, $aModule)) {
list($sModuleName) = ModuleDiscovery::GetModuleName($sModuleId);
$aInstalledModules[$sModuleName] = true;
unset($aPackageModules[$sModuleId]);
}
}
}
private function IsAutoSelectedModule(array $aInstalledModules, string $sModuleId, array $aModule): bool
{
if (($sModuleId === ROOT_MODULE)) {
return false;
}
if (!isset($aModule['auto_select'])) {
return false;
}
try {
SetupInfo::SetSelectedModules($aInstalledModules);
return DependencyExpression::GetPhpExpressionEvaluator()->ParseAndEvaluateBooleanExpression($aModule['auto_select']);
} catch (Exception $e) {
IssueLog::Error('Error evaluating module auto-select', null, [
'module' => $sModuleId,
'error' => $e->getMessage(),
'evaluated code' => $aModule['auto_select'],
'stacktrace' => $e->getTraceAsString(),
]);
}
return false;
}
private function ProcessAutoSelectModules(array $aPackageModules, array &$aInstalledModules): void
{
foreach ($aPackageModules as $sModuleId => $aModule) {
if (($sModuleId !== ROOT_MODULE) && isset($aModule['auto_select'])) {
try {
SetupInfo::SetSelectedModules($aInstalledModules);
$bSelected = DependencyExpression::GetPhpExpressionEvaluator()->ParseAndEvaluateBooleanExpression($aModule['auto_select']);
if ($bSelected) {
list($sModuleName) = ModuleDiscovery::GetModuleName($sModuleId);
$aInstalledModules[$sModuleName] = true;
}
} catch (Exception $e) {
IssueLog::Error('Error evaluating module auto-select', null, [
'module' => $sModuleId,
'error' => $e->getMessage(),
'evaluated code' => $aModule['auto_select'],
'stacktrace' => $e->getTraceAsString(),
]);
}
if ($this->IsAutoSelectedModule($aInstalledModules, $sModuleId, $aModule)) {
list($sModuleName) = ModuleDiscovery::GetModuleName($sModuleId);
$aInstalledModules[$sModuleName] = true;
}
}
}
@@ -186,5 +212,4 @@ class InstallationChoicesToModuleConverter
}
}
}
}

View File

@@ -22,35 +22,379 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase
ModuleDiscovery::ResetCache();
}
public function NonItilExtensionProvider()
public function testGetModulesWithXmlInstallationFile_UsualCustomerPackagesWithNonITIL()
{
return [
'all NON ITIL extensions + INCLUDING known-error-mgt' => [
'aInstallationChoices' => $this->GetSelectedNonItilExtensions(true, true),
'bKnownMgtSelected' => true,
'bCoreMgtSelected' => true,
],
/*'all NON ITIL extensions WITHOUT known-error-mgt' => [
'aInstallationChoices' => $this->GetSelectedNonItilExtensions(true, false),
'bKnownMgtSelected' => false,
'bCoreMgtSelected' => true,
],
'all NON ITIL extensions WITHOUT core mandatory ones + INCLUDING known-error-mgt' => [
'aInstallationChoices' => $this->GetSelectedNonItilExtensions(false, true),
'bKnownMgtSelected' => true,
'bCoreMgtSelected' => false,
],
'all NON ITIL extensions WITHOUT core mandatory ones and WITHOUT known-error-mgt' => [
'aInstallationChoices' => $this->GetSelectedNonItilExtensions(false, false),
'bKnownMgtSelected' => false,
'bCoreMgtSelected' => false,
],*/
$aSearchDirs = $this->GivenModuleDiscoveryInit();
$aInstalledModules = InstallationChoicesToModuleConverter::GetInstance()->GetModules(
$this->GivenNonItilChoices(),
$aSearchDirs,
__DIR__.'/ressources/installation.xml'
);
$aExpected = [
'authent-cas/3.3.0',
'authent-external/3.3.0',
'authent-ldap/3.3.0',
'authent-local/3.3.0',
'combodo-backoffice-darkmoon-theme/3.3.0',
'combodo-backoffice-fullmoon-high-contrast-theme/3.3.0',
'combodo-backoffice-fullmoon-protanopia-deuteranopia-theme/3.3.0',
'combodo-backoffice-fullmoon-tritanopia-theme/3.3.0',
'itop-attachments/3.3.0',
'itop-backup/3.3.0',
'itop-config/3.3.0',
'itop-files-information/3.3.0',
'itop-portal-base/3.3.0',
'itop-portal/3.3.0',
'itop-profiles-itil/3.3.0',
'itop-sla-computation/3.3.0',
'itop-structure/3.3.0',
'itop-themes-compat/3.3.0',
'itop-tickets/3.3.0',
'itop-welcome-itil/3.3.0',
'combodo-db-tools/3.3.0',
'itop-config-mgmt/3.3.0',
'itop-core-update/3.3.0',
'itop-datacenter-mgmt/3.3.0',
'itop-endusers-devices/3.3.0',
'itop-faq-light/3.3.0',
'itop-hub-connector/3.3.0',
'itop-knownerror-mgmt/3.3.0',
'itop-oauth-client/3.3.0',
'itop-request-mgmt/3.3.0',
'itop-service-mgmt/3.3.0',
'itop-storage-mgmt/3.3.0',
'itop-virtualization-mgmt/3.3.0',
'itop-bridge-cmdb-services/3.3.0',
'itop-bridge-cmdb-ticket/3.3.0',
'itop-bridge-datacenter-mgmt-services/3.3.0',
'itop-bridge-endusers-devices-services/3.3.0',
'itop-bridge-storage-mgmt-services/3.3.0',
'itop-bridge-virtualization-mgmt-services/3.3.0',
'itop-bridge-virtualization-storage/3.3.0',
'itop-change-mgmt/3.3.0',
];
$this->assertEquals($aExpected, $aInstalledModules);
}
private function GetSelectedNonItilExtensions(bool $coreExtensionIncluded, bool $bKnownMgtIncluded): array
public function testGetModulesWithXmlInstallationFile_UsualCustomerPackagesWithITIL()
{
$aExtensions = [
$aSearchDirs = $this->GivenModuleDiscoveryInit();
$aInstalledModules = InstallationChoicesToModuleConverter::GetInstance()->GetModules(
$this->GivenItilChoices(),
$aSearchDirs,
__DIR__.'/ressources/installation.xml'
);
$aExpected = [
'authent-cas/3.3.0',
'authent-external/3.3.0',
'authent-ldap/3.3.0',
'authent-local/3.3.0',
'combodo-backoffice-darkmoon-theme/3.3.0',
'combodo-backoffice-fullmoon-high-contrast-theme/3.3.0',
'combodo-backoffice-fullmoon-protanopia-deuteranopia-theme/3.3.0',
'combodo-backoffice-fullmoon-tritanopia-theme/3.3.0',
'itop-attachments/3.3.0',
'itop-backup/3.3.0',
'itop-config/3.3.0',
'itop-files-information/3.3.0',
'itop-portal-base/3.3.0',
'itop-portal/3.3.0',
'itop-profiles-itil/3.3.0',
'itop-sla-computation/3.3.0',
'itop-structure/3.3.0',
'itop-themes-compat/3.3.0',
'itop-tickets/3.3.0',
'itop-welcome-itil/3.3.0',
'combodo-db-tools/3.3.0',
'itop-config-mgmt/3.3.0',
'itop-core-update/3.3.0',
'itop-datacenter-mgmt/3.3.0',
'itop-endusers-devices/3.3.0',
'itop-hub-connector/3.3.0',
'itop-incident-mgmt-itil/3.3.0',
'itop-oauth-client/3.3.0',
'itop-request-mgmt-itil/3.3.0',
'itop-service-mgmt/3.3.0',
'itop-storage-mgmt/3.3.0',
'itop-virtualization-mgmt/3.3.0',
'itop-bridge-cmdb-services/3.3.0',
'itop-bridge-cmdb-ticket/3.3.0',
'itop-bridge-datacenter-mgmt-services/3.3.0',
'itop-bridge-endusers-devices-services/3.3.0',
'itop-bridge-storage-mgmt-services/3.3.0',
'itop-bridge-virtualization-mgmt-services/3.3.0',
'itop-bridge-virtualization-storage/3.3.0',
'itop-change-mgmt-itil/3.3.0',
'itop-full-itil/3.3.0',
];
$this->assertEquals($aExpected, $aInstalledModules);
}
public function testGetModulesWithXmlInstallationFile_LegacyPackages()
{
$aSearchDirs = $this->GivenModuleDiscoveryInit();
//no choices means all default ones...
$aNoInstallationChoices = [];
$aInstalledModules = InstallationChoicesToModuleConverter::GetInstance()->GetModules(
$aNoInstallationChoices,
$aSearchDirs
);
$aExpected = [
'authent-cas/3.3.0',
'authent-external/3.3.0',
'authent-ldap/3.3.0',
'authent-local/3.3.0',
'combodo-backoffice-darkmoon-theme/3.3.0',
'combodo-backoffice-fullmoon-high-contrast-theme/3.3.0',
'combodo-backoffice-fullmoon-protanopia-deuteranopia-theme/3.3.0',
'combodo-backoffice-fullmoon-tritanopia-theme/3.3.0',
'itop-backup/3.3.0',
'itop-config/3.3.0',
'itop-files-information/3.3.0',
'itop-portal-base/3.3.0',
'itop-profiles-itil/3.3.0',
'itop-sla-computation/3.3.0',
'itop-structure/3.3.0',
'itop-welcome-itil/3.3.0',
];
$this->assertEquals($aExpected, $aInstalledModules);
}
public function testIsDefaultModule_RootModule()
{
$sModuleId = ROOT_MODULE;
$aModuleInfo = ['category' => 'authentication', 'visible' => false];
$this->assertFalse($this->CallIsDefault($sModuleId, $aModuleInfo));
}
public function testIsDefaultModule_Autoselect()
{
$sModuleId = 'autoselect_module';
$aModuleInfo = ['category' => 'authentication', 'visible' => false, 'auto_select' => true];
$this->assertFalse($this->CallIsDefault($sModuleId, $aModuleInfo));
}
public function testIsDefaultModule_AuthenticationModule()
{
$sModuleId = 'authentication_module';
$aModuleInfo = ['category' => 'authentication', 'visible' => true];
$this->assertTrue($this->CallIsDefault($sModuleId, $aModuleInfo));
}
public function testIsDefaultModule_HiddenModule()
{
$sModuleId = 'hidden_module';
$aModuleInfo = ['category' => 'business', 'visible' => false];
$this->assertTrue($this->CallIsDefault($sModuleId, $aModuleInfo));
}
public function testIsDefaultModule_OtherTypeOfModules()
{
$sModuleId = 'any_module';
$aModuleInfo = ['category' => 'business', 'visible' => true];
$this->assertFalse($this->CallIsDefault($sModuleId, $aModuleInfo));
}
private function CallIsDefault($sModuleId, $aModuleInfo): bool
{
return $this->InvokeNonPublicMethod(InstallationChoicesToModuleConverter::class, 'IsDefaultModule', InstallationChoicesToModuleConverter::GetInstance(), [$sModuleId, $aModuleInfo]);
}
public function testIsAutoSelectedModule_RootModule()
{
$sModuleId = ROOT_MODULE;
$aModuleInfo = ['auto_select' => true];
$this->assertFalse($this->CallIsAutoSelectedModule([], $sModuleId, $aModuleInfo));
}
public function testIsAutoSelectedModule_NoAutoselect()
{
$sModuleId = 'autoselect_module';
$aModuleInfo = [];
$this->assertFalse($this->CallIsAutoSelectedModule([], $sModuleId, $aModuleInfo));
}
public function testIsAutoSelectedModule_BasicTrue()
{
$sModuleId = "any_module";
$aModuleInfo = ['auto_select' => true];
$this->assertTrue($this->CallIsAutoSelectedModule([], $sModuleId, $aModuleInfo));
}
public function testIsAutoSelectedModule_BasicFalse()
{
$sModuleId = "any_module";
$aModuleInfo = ['auto_select' => false];
$this->assertFalse($this->CallIsAutoSelectedModule([], $sModuleId, $aModuleInfo));
}
public function testIsAutoSelectedModule_UseInstalledModulesForComputation()
{
$sModuleId = "any_module";
$aModuleInfo = ['auto_select' => 'SetupInfo::ModuleIsSelected("a") && SetupInfo::ModuleIsSelected("b")'];
$aInstalledModules = ['a' => true, 'b' => true];
$this->assertTrue($this->CallIsAutoSelectedModule($aInstalledModules, $sModuleId, $aModuleInfo));
}
private function CallIsAutoSelectedModule($aInstalledModules, $sModuleId, $aModuleInfo): bool
{
return $this->InvokeNonPublicMethod(InstallationChoicesToModuleConverter::class, 'IsAutoSelectedModule', InstallationChoicesToModuleConverter::GetInstance(), [$aInstalledModules, $sModuleId, $aModuleInfo]);
}
public function testProcessInstallationChoices_Default()
{
$aRes = [];
$aInstallationDescription = $this->GivenInstallationChoiceDescription();
$this->CallProcessInstallationChoices([], $aInstallationDescription, $aRes);
$aExpected = [
'combodo-backoffice-darkmoon-theme' => true,
'combodo-backoffice-fullmoon-high-contrast-theme' => true,
'combodo-backoffice-fullmoon-protanopia-deuteranopia-theme' => true,
'combodo-backoffice-fullmoon-tritanopia-theme' => true,
'itop-attachments' => true,
'itop-backup' => true,
'itop-config' => true,
'itop-files-information' => true,
'itop-profiles-itil' => true,
'itop-structure' => true,
'itop-themes-compat' => true,
'itop-tickets' => true,
'itop-welcome-itil' => true,
'combodo-db-tools' => true,
'itop-config-mgmt' => true,
'itop-core-update' => true,
'itop-hub-connector' => true,
'itop-oauth-client' => true,
'combodo-password-expiration' => true,
'combodo-webhook-integration' => true,
'combodo-my-account-user-info' => true,
'authent-token' => true,
];
$this->assertEquals($aExpected, $aRes);
}
public function testProcessInstallationChoices_NonItilChoices()
{
$aRes = [];
$aInstallationDescription = $this->GivenInstallationChoiceDescription();
$this->CallProcessInstallationChoices($this->GivenNonItilChoices(), $aInstallationDescription, $aRes);
$aExpected = [
'combodo-backoffice-darkmoon-theme' => true,
'combodo-backoffice-fullmoon-high-contrast-theme' => true,
'combodo-backoffice-fullmoon-protanopia-deuteranopia-theme' => true,
'combodo-backoffice-fullmoon-tritanopia-theme' => true,
'itop-attachments' => true,
'itop-backup' => true,
'itop-config' => true,
'itop-files-information' => true,
'itop-profiles-itil' => true,
'itop-structure' => true,
'itop-themes-compat' => true,
'itop-tickets' => true,
'itop-welcome-itil' => true,
'combodo-db-tools' => true,
'itop-config-mgmt' => true,
'itop-core-update' => true,
'itop-hub-connector' => true,
'itop-oauth-client' => true,
'combodo-password-expiration' => true,
'combodo-webhook-integration' => true,
'combodo-my-account-user-info' => true,
'authent-token' => true,
'itop-datacenter-mgmt' => true,
'itop-endusers-devices' => true,
'itop-storage-mgmt' => true,
'itop-virtualization-mgmt' => true,
'itop-service-mgmt' => true,
'itop-request-mgmt' => true,
'itop-portal' => true,
'itop-portal-base' => true,
'itop-change-mgmt' => true,
'itop-faq-light' => true,
'itop-knownerror-mgmt' => true,
];
$this->assertEquals($aExpected, $aRes);
}
public function testProcessInstallationChoices_ItilChoices()
{
$aRes = [];
$aInstallationDescription = $this->GivenInstallationChoiceDescription();
$this->CallProcessInstallationChoices($this->GivenItilChoices(), $aInstallationDescription, $aRes);
$aExpected = [
'combodo-backoffice-darkmoon-theme' => true,
'combodo-backoffice-fullmoon-high-contrast-theme' => true,
'combodo-backoffice-fullmoon-protanopia-deuteranopia-theme' => true,
'combodo-backoffice-fullmoon-tritanopia-theme' => true,
'itop-attachments' => true,
'itop-backup' => true,
'itop-config' => true,
'itop-files-information' => true,
'itop-profiles-itil' => true,
'itop-structure' => true,
'itop-themes-compat' => true,
'itop-tickets' => true,
'itop-welcome-itil' => true,
'combodo-db-tools' => true,
'itop-config-mgmt' => true,
'itop-core-update' => true,
'itop-hub-connector' => true,
'itop-oauth-client' => true,
'combodo-password-expiration' => true,
'combodo-webhook-integration' => true,
'combodo-my-account-user-info' => true,
'authent-token' => true,
'itop-datacenter-mgmt' => true,
'itop-endusers-devices' => true,
'itop-storage-mgmt' => true,
'itop-virtualization-mgmt' => true,
'itop-service-mgmt' => true,
'itop-portal' => true,
'itop-portal-base' => true,
'itop-request-mgmt-itil' => true,
'itop-incident-mgmt-itil' => true,
'itop-change-mgmt-itil' => true,
];
$this->assertEquals($aExpected, $aRes);
}
private function CallProcessInstallationChoices(array $aInstallationChoices, array $aInstallationDescription, array &$aInstalledModules)
{
$this->InvokeNonPublicMethod(
InstallationChoicesToModuleConverter::class,
'ProcessInstallationChoices',
InstallationChoicesToModuleConverter::GetInstance(),
[$aInstallationChoices, $aInstallationDescription, &$aInstalledModules]
);
}
private function GivenInstallationChoiceDescription(): array
{
$oXMLParameters = new XMLParameters(__DIR__."/ressources/installation.xml");
return $oXMLParameters->Get('steps', []);
}
private function GivenAllModules(): array
{
return json_decode(file_get_contents(__DIR__.'/ressources/available_modules.json'), true);
}
private function GivenNonItilChoices(): array
{
return [
'itop-config-mgmt-core',
'itop-config-mgmt-datacenter',
'itop-config-mgmt-end-user',
@@ -60,151 +404,33 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase
'itop-ticket-mgmt-simple-ticket',
'itop-ticket-mgmt-simple-ticket-enhanced-portal',
'itop-change-mgmt-simple',
'itop-kown-error-mgmt',
];
if ($coreExtensionIncluded) {
$aExtensions[] = 'itop-config-mgmt-core';
}
if ($bKnownMgtIncluded) {
$aExtensions[] = 'itop-kown-error-mgmt';
}
return $this->TransformExtensionArrayToDictionnary($aExtensions);
}
private function TransformExtensionArrayToDictionnary(array $aExtensions)
private function GivenItilChoices(): array
{
$aDict = [];
foreach ($aExtensions as $sExtId) {
$aDict[$sExtId] = [];
}
return [
'itop-config-mgmt-datacenter',
'itop-config-mgmt-end-user',
'itop-config-mgmt-storage',
'itop-config-mgmt-virtualization',
'itop-service-mgmt-enterprise',
'itop-ticket-mgmt-itil',
'itop-ticket-mgmt-itil-user-request',
'itop-ticket-mgmt-itil-incident',
'itop-ticket-mgmt-itil-enhanced-portal',
'itop-change-mgmt-itil',
'itop-config-mgmt-core',
return $aDict;
}
/**
* @dataProvider NonItilExtensionProvider
*/
public function testGetInstalledModules(array $aInstallationChoices, bool $bKnownMgtSelected, bool $bCoreMgtSelected)
{
$aSearchDirs = $this->GivenModuleDiscoveryInit();
$aExpectedModulesIds = $this->GetExpectedNonItilInstalledModules($bKnownMgtSelected, $bCoreMgtSelected);
$aInstalledModules = InstallationChoicesToModuleConverter::GetInstance()->GetModules(
$aInstallationChoices,
$aSearchDirs,
__DIR__.'/ressources/installation.xml'
);
sort($aInstalledModules);
$this->assertEquals($aExpectedModulesIds, $aInstalledModules);
}
public function testGetInstalledModules_NoInstallationXML()
{
$aSearchDirs = $this->GivenModuleDiscoveryInit();
$aInstallationChoices = json_decode(file_get_contents(__DIR__."/ressources/installation_choices_when_no_xml_file.json"), true);
$aExpectedModulesIds = [
'authent-cas/3.3.0',
'authent-external/3.3.0',
'authent-ldap/3.3.0',
'authent-local/3.3.0',
'combodo-backoffice-darkmoon-theme/3.3.0',
'combodo-backoffice-fullmoon-high-contrast-theme/3.3.0',
'combodo-backoffice-fullmoon-protanopia-deuteranopia-theme/3.3.0',
'combodo-backoffice-fullmoon-tritanopia-theme/3.3.0',
'combodo-db-tools/3.3.0',
'itop-attachments/3.3.0',
'itop-backup/3.3.0',
'itop-bridge-cmdb-services/3.3.0',
'itop-config-mgmt/3.3.0',
'itop-config/3.3.0',
'itop-core-update/3.3.0',
'itop-faq-light/3.3.0',
'itop-files-information/3.3.0',
'itop-portal-base/3.3.0',
'itop-profiles-itil/3.3.0',
'itop-request-mgmt/3.3.0',
'itop-service-mgmt/3.3.0',
'itop-sla-computation/3.3.0',
'itop-structure/3.3.0',
'itop-welcome-itil/3.3.0',
];
$aInstalledModules = InstallationChoicesToModuleConverter::GetInstance()->GetModules(
$aInstallationChoices,
$aSearchDirs,
null
);
sort($aInstalledModules);
$this->assertEquals($aExpectedModulesIds, $aInstalledModules);
}
private function GetExpectedNonItilInstalledModules(bool $bKnownMgtSelected, bool $bCoreMgtSelected): array
{
$aExpectedInstalledModules = [
'itop-structure/3.3.0',
'itop-sla-computation/3.3.0',
'itop-portal-base/3.3.0',
'itop-bridge-virtualization-mgmt-services/3.3.0',
'itop-request-mgmt/3.3.0',
'itop-welcome-itil/3.3.0',
'itop-profiles-itil/3.3.0',
'authent-ldap/3.3.0',
'authent-local/3.3.0',
'itop-oauth-client/3.3.0',
'itop-virtualization-mgmt/3.3.0',
'itop-core-update/3.3.0',
'combodo-backoffice-fullmoon-high-contrast-theme/3.3.0',
'itop-bridge-cmdb-services/3.3.0',
'itop-files-information/3.3.0',
'itop-attachments/3.3.0',
'itop-bridge-endusers-devices-services/3.3.0',
'itop-endusers-devices/3.3.0',
'itop-backup/3.3.0',
'itop-config/3.3.0',
'itop-bridge-storage-mgmt-services/3.3.0',
'combodo-backoffice-fullmoon-tritanopia-theme/3.3.0',
'combodo-backoffice-darkmoon-theme/3.3.0',
'itop-portal/3.3.0',
'itop-hub-connector/3.3.0',
'itop-bridge-datacenter-mgmt-services/3.3.0',
'itop-themes-compat/3.3.0',
'itop-tickets/3.3.0',
'itop-storage-mgmt/3.3.0',
'combodo-db-tools/3.3.0',
'combodo-backoffice-fullmoon-protanopia-deuteranopia-theme/3.3.0',
'authent-cas/3.3.0',
'itop-datacenter-mgmt/3.3.0',
'itop-bridge-virtualization-storage/3.3.0',
'authent-external/3.3.0',
'itop-bridge-cmdb-ticket/3.3.0',
'itop-change-mgmt/3.3.0',
'itop-service-mgmt/3.3.0',
];
if ($bCoreMgtSelected) {
$aExpectedInstalledModules [] = 'itop-config-mgmt/3.3.0';
}
if ($bKnownMgtSelected) {
$aExpectedInstalledModules [] = 'itop-knownerror-mgmt/3.3.0';
$aExpectedInstalledModules [] = 'itop-faq-light/3.3.0';
}
sort($aExpectedInstalledModules);
return $aExpectedInstalledModules;
}
private function GivenModuleDiscoveryInit(): array
{
$aSearchDirs = [APPROOT.'datamodels/2.x'];
$this->SetNonPublicStaticProperty(ModuleDiscovery::class, 'm_aSearchDirs', $aSearchDirs);
$aAllModules = json_decode(file_get_contents(__DIR__.'/ressources/available_modules.json'), true);
$aAllModules = $this->GivenAllModules();
$this->SetNonPublicStaticProperty(ModuleDiscovery::class, 'm_aModules', $aAllModules);
return $aSearchDirs;
}