diff --git a/setup/moduleinstallation/InstallationChoicesToModuleConverter.php b/setup/moduleinstallation/InstallationChoicesToModuleConverter.php index 9a6e03835..afb88d939 100644 --- a/setup/moduleinstallation/InstallationChoicesToModuleConverter.php +++ b/setup/moduleinstallation/InstallationChoicesToModuleConverter.php @@ -79,7 +79,7 @@ class InstallationChoicesToModuleConverter $aInstalledModules[$sModuleName] = true; } } else { - $this->ProcessInstallationChoices($aInstallationChoices, $aInstallationDescription, $aInstalledModules); + $this->GetModuleNamesFromInstallationChoices($aInstallationChoices, $aInstallationDescription, $aInstalledModules); } $this->ProcessAutoSelectModules($aPackageModules, $aInstalledModules); @@ -150,19 +150,19 @@ class InstallationChoicesToModuleConverter } } - private function ProcessInstallationChoices(array $aInstallationChoices, array $aInstallationDescription, array &$aInstalledModules): void + private function GetModuleNamesFromInstallationChoices(array $aInstallationChoices, array $aInstallationDescription, array &$aModuleNames): void { foreach ($aInstallationDescription as $aStepInfo) { $aOptions = $aStepInfo['options'] ?? null; if (is_array($aOptions)) { foreach ($aOptions as $aChoiceInfo) { - $this->ProcessSelectedChoice($aInstallationChoices, $aChoiceInfo, $aInstalledModules); + $this->ProcessSelectedChoice($aInstallationChoices, $aChoiceInfo, $aModuleNames); } } $aOptions = $aStepInfo['alternatives'] ?? null; if (is_array($aOptions)) { foreach ($aOptions as $aChoiceInfo) { - $this->ProcessSelectedChoice($aInstallationChoices, $aChoiceInfo, $aInstalledModules); + $this->ProcessSelectedChoice($aInstallationChoices, $aChoiceInfo, $aModuleNames); } } } 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 c611e2fc3..756d1a176 100644 --- a/tests/php-unit-tests/unitary-tests/setup/moduleinstallation/InstallationChoicesToModuleConverterTest.php +++ b/tests/php-unit-tests/unitary-tests/setup/moduleinstallation/InstallationChoicesToModuleConverterTest.php @@ -22,6 +22,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase ModuleDiscovery::ResetCache(); } + //integration test public function testGetModulesWithXmlInstallationFile_UsualCustomerPackagesWithNonITIL() { $aSearchDirs = $this->GivenModuleDiscoveryInit(); @@ -78,6 +79,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase $this->assertEquals($aExpected, $aInstalledModules); } + //integration test public function testGetModulesWithXmlInstallationFile_UsualCustomerPackagesWithITIL() { $aSearchDirs = $this->GivenModuleDiscoveryInit(); @@ -134,6 +136,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase $this->assertEquals($aExpected, $aInstalledModules); } + //integration test public function testGetModulesWithXmlInstallationFile_LegacyPackages() { $aSearchDirs = $this->GivenModuleDiscoveryInit(); @@ -167,35 +170,35 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase $this->assertEquals($aExpected, $aInstalledModules); } - public function testIsDefaultModule_RootModule() + public function testIsDefaultModule_RootModuleShouldNeverBeDefault() { $sModuleId = ROOT_MODULE; $aModuleInfo = ['category' => 'authentication', 'visible' => false]; $this->assertFalse($this->CallIsDefault($sModuleId, $aModuleInfo)); } - public function testIsDefaultModule_Autoselect() + public function testIsDefaultModule_AutoselectShouldNeverBeDefault() { $sModuleId = 'autoselect_module'; $aModuleInfo = ['category' => 'authentication', 'visible' => false, 'auto_select' => true]; $this->assertFalse($this->CallIsDefault($sModuleId, $aModuleInfo)); } - public function testIsDefaultModule_AuthenticationModule() + public function testIsDefaultModule_AuthenticationModuleShouldBeDefault() { $sModuleId = 'authentication_module'; $aModuleInfo = ['category' => 'authentication', 'visible' => true]; $this->assertTrue($this->CallIsDefault($sModuleId, $aModuleInfo)); } - public function testIsDefaultModule_HiddenModule() + public function testIsDefaultModule_HiddenModuleShouldBeDefault() { $sModuleId = 'hidden_module'; $aModuleInfo = ['category' => 'business', 'visible' => false]; $this->assertTrue($this->CallIsDefault($sModuleId, $aModuleInfo)); } - public function testIsDefaultModule_OtherTypeOfModules() + public function testIsDefaultModule_NonModuleDefaultCase() { $sModuleId = 'any_module'; $aModuleInfo = ['category' => 'business', 'visible' => true]; @@ -207,34 +210,24 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase return $this->InvokeNonPublicMethod(InstallationChoicesToModuleConverter::class, 'IsDefaultModule', InstallationChoicesToModuleConverter::GetInstance(), [$sModuleId, $aModuleInfo]); } - public function testIsAutoSelectedModule_RootModule() + public function testIsAutoSelectedModule_RootModuleShouldNeverBeAutoSelect() { $sModuleId = ROOT_MODULE; $aModuleInfo = ['auto_select' => true]; $this->assertFalse($this->CallIsAutoSelectedModule([], $sModuleId, $aModuleInfo)); } - public function testIsAutoSelectedModule_NoAutoselect() + public function testIsAutoSelectedModule_NoAutoselectByDefault() { $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)); - } - + /** + * @return void + * cf DependencyExpression dedicated tests + */ public function testIsAutoSelectedModule_UseInstalledModulesForComputation() { $sModuleId = "any_module"; @@ -253,7 +246,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase $aRes = []; $aInstallationDescription = $this->GivenInstallationChoiceDescription(); - $this->CallProcessInstallationChoices([], $aInstallationDescription, $aRes); + $this->CallGetModuleNamesFromInstallationChoices([], $aInstallationDescription, $aRes); $aExpected = [ 'combodo-backoffice-darkmoon-theme' => true, @@ -287,7 +280,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase $aRes = []; $aInstallationDescription = $this->GivenInstallationChoiceDescription(); - $this->CallProcessInstallationChoices($this->GivenNonItilChoices(), $aInstallationDescription, $aRes); + $this->CallGetModuleNamesFromInstallationChoices($this->GivenNonItilChoices(), $aInstallationDescription, $aRes); $aExpected = [ 'combodo-backoffice-darkmoon-theme' => true, @@ -332,7 +325,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase $aRes = []; $aInstallationDescription = $this->GivenInstallationChoiceDescription(); - $this->CallProcessInstallationChoices($this->GivenItilChoices(), $aInstallationDescription, $aRes); + $this->CallGetModuleNamesFromInstallationChoices($this->GivenItilChoices(), $aInstallationDescription, $aRes); $aExpected = [ 'combodo-backoffice-darkmoon-theme' => true, @@ -371,13 +364,13 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase $this->assertEquals($aExpected, $aRes); } - private function CallProcessInstallationChoices(array $aInstallationChoices, array $aInstallationDescription, array &$aInstalledModules) + private function CallGetModuleNamesFromInstallationChoices(array $aInstallationChoices, array $aInstallationDescription, array &$aModuleNames) { $this->InvokeNonPublicMethod( InstallationChoicesToModuleConverter::class, - 'ProcessInstallationChoices', + 'GetModuleNamesFromInstallationChoices', InstallationChoicesToModuleConverter::GetInstance(), - [$aInstallationChoices, $aInstallationDescription, &$aInstalledModules] + [$aInstallationChoices, $aInstallationDescription, &$aModuleNames] ); }