N°9009 Add phpunit test to GetSelectedModules

This commit is contained in:
Timmy38
2026-02-26 10:28:52 +01:00
committed by GitHub
parent 329191aa47
commit 9b6d321ab0
4 changed files with 287 additions and 10 deletions

View File

@@ -48,7 +48,7 @@ class WizStepModulesChoice extends WizardStep
*/
protected bool $bChoicesFromDatabase;
private array $aAnalyzeInstallationModules;
private array $aAnalyzeInstallationModules = [];
private ?MissingDependencyException $oMissingDependencyException = null;
public function __construct(WizardController $oWizard, $sCurrentState)
@@ -488,7 +488,7 @@ EOF
*
* @return string A text representation of what will be installed
*/
protected function GetSelectedModules($aInfo, $aSelectedChoices, &$aModules, $sParentId = '', $sDisplayChoices = '', &$aSelectedExtensions = null)
public function GetSelectedModules($aInfo, $aSelectedChoices, &$aModules, $sParentId = '', $sDisplayChoices = '', &$aSelectedExtensions = null)
{
if ($sParentId == '') {
// Check once (before recursing) that the hidden modules are selected
@@ -501,7 +501,7 @@ EOF
}
}
}
$aOptions = isset($aInfo['options']) ? $aInfo['options'] : [];
$aOptions = $aInfo['options'] ?? [];
foreach ($aOptions as $index => $aChoice) {
$sChoiceId = $sParentId.self::$SEP.$index;
$aModuleInfo = [];
@@ -516,16 +516,19 @@ EOF
(isset($aSelectedChoices[$sChoiceId]) && ($aSelectedChoices[$sChoiceId] == $sChoiceId))) {
$sDisplayChoices .= '<li>'.$aChoice['title'].'</li>';
if (isset($aChoice['modules'])) {
if (count($aChoice['modules']) === 0) {
throw new Exception('Extension '.$aChoice['extension_code'].' does not have any module associated');
}
foreach ($aChoice['modules'] as $sModuleId) {
$bSelected = true;
if (isset($aModuleInfo[$sModuleId])) {
// Test if module has 'auto_select'
$aInfo = $aModuleInfo[$sModuleId];
if (isset($aInfo['auto_select'])) {
$aCurrentModuleInfo = $aModuleInfo[$sModuleId];
if (isset($aCurrentModuleInfo['auto_select'])) {
// Check the module selection
try {
SetupInfo::SetSelectedModules($aModules);
$bSelected = $this->GetPhpExpressionEvaluator()->ParseAndEvaluateBooleanExpression($aInfo['auto_select']);
$bSelected = $this->GetPhpExpressionEvaluator()->ParseAndEvaluateBooleanExpression($aCurrentModuleInfo['auto_select']);
} catch (ModuleFileReaderException $e) {
//logged already
$bSelected = false;
@@ -538,7 +541,6 @@ EOF
}
}
}
$sChoiceType = isset($aChoice['type']) ? $aChoice['type'] : 'wizard_option';
if ($aSelectedExtensions !== null) {
$aSelectedExtensions[] = $aChoice['extension_code'];
}
@@ -552,7 +554,7 @@ EOF
}
}
$aAlternatives = isset($aInfo['alternatives']) ? $aInfo['alternatives'] : [];
$aAlternatives = $aInfo['alternatives'] ?? [];
$sChoiceName = null;
foreach ($aAlternatives as $index => $aChoice) {
$sChoiceId = $sParentId.self::$SEP.$index;