diff --git a/setup/wizardsteps/WizStepModulesChoice.php b/setup/wizardsteps/WizStepModulesChoice.php index 3f6222db9f..4f72b6d940 100644 --- a/setup/wizardsteps/WizStepModulesChoice.php +++ b/setup/wizardsteps/WizStepModulesChoice.php @@ -797,6 +797,10 @@ EOF $bDisabled = !$bDisableUninstallCheck; } + if ($bDisabled) { + $bChecked = $bInstalled; + } + if (isset($aChoice['sub_options'])) { $aOptions = $aChoice['sub_options']['options'] ?? []; foreach ($aOptions as $index => $aSubChoice) { diff --git a/tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php b/tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php index 425f152ab3..f067579257 100644 --- a/tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php +++ b/tests/php-unit-tests/unitary-tests/setup/WizStepModulesChoiceTest.php @@ -718,6 +718,56 @@ class WizStepModulesChoiceTest extends ItopTestCase 'remote' => false, ], ], + '#node17 - An installed non uninstallable extension should be checked and disabled when the "disable uninstallation check" flag is not set, even if it is not selected' => [ + 'aExtensionsOnDiskOrDb' => [ + 'itop-ext1' => [ + 'installed' => true, + ], + ], + 'aWizardStepDefinition' => [ + 'extension_code' => 'itop-ext1', + 'uninstallable' => false, + ], + 'aSelectedComponents' => [], + 'bDisableUninstallChecks' => false, + 'aExpectedFlags' => [ + 'uninstallable' => false, + 'missing' => false, + 'installed' => true, + 'disabled' => true, + 'checked' => true, + 'dependency_issue' => false, + 'mandatory' => false, + 'remote' => false, + ], + ], + '#node18 - An installed but not selected extension with missing dependencies without force uninstall should be checked and disabled, even if it is not selected' => [ + 'aExtensionsOnDiskOrDb' => [ + 'itop-ext1' => [ + 'installed' => true, + 'missing_dependencies' => [ + 'itop-ext1-1', + ], + ], + ], + 'aWizardStepDefinition' => [ + 'extension_code' => 'itop-ext1', + 'uninstallable' => true, + 'missing_dependencies' => true, + ], + 'aSelectedComponents' => [], + 'bDisableUninstallChecks' => false, + 'aExpectedFlags' => [ + 'uninstallable' => true, + 'missing' => false, + 'installed' => true, + 'disabled' => true, + 'checked' => true, + 'dependency_issue' => true, + 'mandatory' => false, + 'remote' => false, + ], + ], ]; }