mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°9009 Rebase
This commit is contained in:
@@ -48,7 +48,7 @@ class WizStepModulesChoice extends WizardStep
|
|||||||
*/
|
*/
|
||||||
protected bool $bChoicesFromDatabase;
|
protected bool $bChoicesFromDatabase;
|
||||||
|
|
||||||
private array $aAnalyzeInstallationModules;
|
private array $aAnalyzeInstallationModules = [];
|
||||||
private ?MissingDependencyException $oMissingDependencyException = null;
|
private ?MissingDependencyException $oMissingDependencyException = null;
|
||||||
|
|
||||||
public function __construct(WizardController $oWizard, $sCurrentState)
|
public function __construct(WizardController $oWizard, $sCurrentState)
|
||||||
@@ -486,7 +486,7 @@ EOF
|
|||||||
*
|
*
|
||||||
* @return string A text representation of what will be installed
|
* @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 == '') {
|
if ($sParentId == '') {
|
||||||
// Check once (before recursing) that the hidden modules are selected
|
// Check once (before recursing) that the hidden modules are selected
|
||||||
@@ -514,6 +514,9 @@ EOF
|
|||||||
(isset($aSelectedChoices[$sChoiceId]) && ($aSelectedChoices[$sChoiceId] == $sChoiceId))) {
|
(isset($aSelectedChoices[$sChoiceId]) && ($aSelectedChoices[$sChoiceId] == $sChoiceId))) {
|
||||||
$sDisplayChoices .= '<li>'.$aChoice['title'].'</li>';
|
$sDisplayChoices .= '<li>'.$aChoice['title'].'</li>';
|
||||||
if (isset($aChoice['modules'])) {
|
if (isset($aChoice['modules'])) {
|
||||||
|
if (count($aChoice['modules']) === 0) {
|
||||||
|
throw new Exception('Setup option does not have any module associated');
|
||||||
|
}
|
||||||
foreach ($aChoice['modules'] as $sModuleId) {
|
foreach ($aChoice['modules'] as $sModuleId) {
|
||||||
$bSelected = true;
|
$bSelected = true;
|
||||||
if (isset($aModuleInfo[$sModuleId])) {
|
if (isset($aModuleInfo[$sModuleId])) {
|
||||||
|
|||||||
@@ -559,4 +559,99 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
|||||||
|
|
||||||
return $aSteps[$index] ?? null;
|
return $aSteps[$index] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ProviderGetSelectedModules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'No extension selected' => [
|
||||||
|
'aSelected' => [],
|
||||||
|
'aExpectedModules' => [],
|
||||||
|
'aExpectedExtensions' => [],
|
||||||
|
],
|
||||||
|
'One extension selected' => [
|
||||||
|
'aSelected' => ['_0' => '_0'],
|
||||||
|
'aExpectedModules' => ['combodo-sample-module' => true],
|
||||||
|
'aExpectedExtensions' => ['combodo-sample'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider ProviderGetSelectedModules
|
||||||
|
*/
|
||||||
|
public function testGetSelectedModules($aSelectedExtensions, $aExpectedModules, $aExpectedExtensions)
|
||||||
|
{
|
||||||
|
$aExtensionsMapData = [
|
||||||
|
'combodo-sample' => [
|
||||||
|
'installed' => false,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$this->oStep->setExtensionMap(iTopExtensionsMapFake::createFromArray($aExtensionsMapData, ));
|
||||||
|
|
||||||
|
//GetSelectedModules
|
||||||
|
$aStepInfo = [
|
||||||
|
'title' => 'Extensions',
|
||||||
|
'description' => '',
|
||||||
|
'banner' => '',
|
||||||
|
'options' => [
|
||||||
|
[
|
||||||
|
'extension_code' => 'combodo-sample',
|
||||||
|
'title' => 'Sample extension',
|
||||||
|
'description' => '',
|
||||||
|
'more_info' => '',
|
||||||
|
'default' => true,
|
||||||
|
'modules' => [
|
||||||
|
'combodo-sample-module',
|
||||||
|
],
|
||||||
|
'mandatory' => false,
|
||||||
|
'source_label' => '',
|
||||||
|
'uninstallable' => true,
|
||||||
|
'missing' => false,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$aModules = [];
|
||||||
|
$aExtensions = [];
|
||||||
|
$this->oStep->GetSelectedModules($aStepInfo, $aSelectedExtensions, $aModules, '', '', $aExtensions);
|
||||||
|
$this->assertEquals($aExpectedModules, $aModules);
|
||||||
|
$this->assertEquals($aExpectedExtensions, $aExtensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetSelectedModulesShouldThrowAnExceptionWhenAnySelectedExtensionDoesNotHaveAnyAssociatedModules()
|
||||||
|
{
|
||||||
|
$aExtensionsMapData = [
|
||||||
|
'combodo-sample' => [
|
||||||
|
'installed' => false,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$this->oStep->setExtensionMap(iTopExtensionsMapFake::createFromArray($aExtensionsMapData, ));
|
||||||
|
|
||||||
|
//GetSelectedModules
|
||||||
|
$aStepInfo = [
|
||||||
|
'title' => 'Extensions',
|
||||||
|
'description' => '',
|
||||||
|
'banner' => '',
|
||||||
|
'options' => [
|
||||||
|
[
|
||||||
|
'extension_code' => 'combodo-sample',
|
||||||
|
'title' => 'Sample extension',
|
||||||
|
'description' => '',
|
||||||
|
'more_info' => '',
|
||||||
|
'default' => true,
|
||||||
|
'modules' => [],
|
||||||
|
'mandatory' => false,
|
||||||
|
'source_label' => '',
|
||||||
|
'uninstallable' => true,
|
||||||
|
'missing' => false,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$aModules = [];
|
||||||
|
$aExtensions = [];
|
||||||
|
$this->expectException('Exception');
|
||||||
|
$this->oStep->GetSelectedModules($aStepInfo, ['_0' => '_0'], $aModules, '', '', $aExtensions);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user