diff --git a/datamodels/2.x/itop-core-update/src/Service/RunTimeEnvironmentCoreUpdater.php b/datamodels/2.x/itop-core-update/src/Service/RunTimeEnvironmentCoreUpdater.php index 439d44a0e7..b38a0d682d 100644 --- a/datamodels/2.x/itop-core-update/src/Service/RunTimeEnvironmentCoreUpdater.php +++ b/datamodels/2.x/itop-core-update/src/Service/RunTimeEnvironmentCoreUpdater.php @@ -46,11 +46,9 @@ class RunTimeEnvironmentCoreUpdater extends RunTimeEnvironment */ public function CheckDirectories($sBuildEnv) { - $sBuildDir = APPROOT.'env-'.$sBuildEnv; - $sBuildDir = $sBuildDir.'-build'; - - self::CheckDirectory($sBuildDir); - self::CheckDirectory($sBuildDir); + $sCurrentEnvDir = APPROOT.'env-'.$sBuildEnv; + self::CheckDirectory($sCurrentEnvDir); + self::CheckDirectory($sCurrentEnvDir.'-build'); } /** diff --git a/setup/feature_removal/DryRemovalRuntimeEnvironment.php b/setup/feature_removal/DryRemovalRuntimeEnvironment.php index 4cb259942c..ed86e87e2b 100644 --- a/setup/feature_removal/DryRemovalRuntimeEnvironment.php +++ b/setup/feature_removal/DryRemovalRuntimeEnvironment.php @@ -35,19 +35,6 @@ class DryRemovalRuntimeEnvironment extends RunTimeEnvironment SetupUtils::copydir(APPROOT."/conf/$sSourceEnv", APPROOT."/conf/$sBuildEnv"); $this->DeclareExtensionAsRemoved($this->aExtensionsByCode); - /* - $sSourceDir = MetaModel::GetConfig()->Get('source_dir'); - $aSearchDirs = $this->GetExtraDirsToCompile($sSourceDir); - - $aModulesToLoad = $this->GetModulesToLoad($sSourceEnv, $aSearchDirs); - \SetupLog::Info(__METHOD__, null, ['module_to_load' => $aModulesToLoad]); - - try { - ModuleDiscovery::GetModulesOrderedByDependencies($aSearchDirs, true, $aModulesToLoad); - } catch (\MissingDependencyException $e) { - \IssueLog::Error("Cannot prepare setup due to dependency issue", null, ['msg' => $e->getMessage(), 'modules_to_load' => $aModulesToLoad]); - throw $e; - }*/ } private function DeclareExtensionAsRemoved(array $aExtensionCodes): void diff --git a/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php b/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php index 9d97f9362b..393d309d16 100644 --- a/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php +++ b/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php @@ -197,6 +197,7 @@ abstract class ItopTestCase extends KernelTestCase } SetupUtils::tidydir($sPath); + SetupUtils::rrmdir($sPath); } } diff --git a/tests/php-unit-tests/unitary-tests/setup/moduleinstallation/InstallationChoicesToModuleConverterTest.php b/tests/php-unit-tests/unitary-tests/setup/moduleinstallation/InstallationChoicesToModuleConverterTest.php index 756d1a176d..4aaaacc416 100644 --- a/tests/php-unit-tests/unitary-tests/setup/moduleinstallation/InstallationChoicesToModuleConverterTest.php +++ b/tests/php-unit-tests/unitary-tests/setup/moduleinstallation/InstallationChoicesToModuleConverterTest.php @@ -170,6 +170,109 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase $this->assertEquals($aExpected, $aInstalledModules); } + private function GivenNewExtensionDir($MainDir, $sExtensionCode, $sModuleCode, $sModuleVersion): string + { + $sExtDir = "$MainDir/$sExtensionCode"; + + mkdir($sExtDir, recursive:true); + $sModuleDir = $sExtDir."/$sModuleCode"; + mkdir($sModuleDir); + $sContent = << '$sModuleCode', + 'category' => 'authentication', + 'dependencies' => [], + 'mandatory' => true, + 'visible' => true, + 'datamodel' => [], + 'webservice' => [], + 'data.struct' => [], + 'data.sample' => [], + 'doc.manual_setup' => '', + 'doc.more_information' => '', + ] +); +PHP; + file_put_contents($sModuleDir."/module.$sModuleCode.php", $sContent); + + return $sExtDir; + } + + //integration + public function testGetModules_ComputeAdditionalExtensionDirectories() + { + $aSearchDirs = $this->GivenModuleDiscoveryInit(); + + $MainDir = __DIR__."/ressources/InstallationChoicesToModuleConverterTest"; + $this->aFileToClean [] = $MainDir; + $aExtensionDirs = [ + //should replace same one in the package + $this->GivenNewExtensionDir($MainDir, 'itop-oauth-client', 'itop-oauth-client', '6.6.0'), + //not in the package => should be added after installation + $this->GivenNewExtensionDir($MainDir, 'shadok', 'gabu-zomeu', '1.2.3'), + //same one in the package should remain + $this->GivenNewExtensionDir($MainDir, 'itop-files-information', 'itop-files-information', '3.3.0'), + ]; + + $aInstalledModules = InstallationChoicesToModuleConverter::GetInstance()->GetModules( + $this->GivenNonItilChoices(), + $aSearchDirs, + __DIR__.'/ressources/installation.xml', + $aExtensionDirs, + ); + + $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/6.6.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', + 'gabu-zomeu/1.2.3', + ]; + $this->assertEquals($aExpected, $aInstalledModules); + } + public function testIsDefaultModule_RootModuleShouldNeverBeDefault() { $sModuleId = ROOT_MODULE; @@ -423,8 +526,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase { $aSearchDirs = [APPROOT.'datamodels/2.x']; $this->SetNonPublicStaticProperty(ModuleDiscovery::class, 'm_aSearchDirs', $aSearchDirs); - $aAllModules = $this->GivenAllModules(); - $this->SetNonPublicStaticProperty(ModuleDiscovery::class, 'm_aModules', $aAllModules); + $this->SetNonPublicStaticProperty(ModuleDiscovery::class, 'm_aModules', $this->GivenAllModules()); return $aSearchDirs; } }