mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-04 07:58:46 +02:00
N°9009 - fix removing sources of a mandatory module
This commit is contained in:
@@ -478,6 +478,7 @@ EOF
|
||||
* @param string $sParentId Used for recursion
|
||||
*
|
||||
* @return string A text representation of what will be installed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function GetSelectedModules($aInfo, $aSelectedChoices, &$aModules, $sParentId = '', $sDisplayChoices = '', &$aSelectedExtensions = null)
|
||||
{
|
||||
@@ -507,8 +508,8 @@ 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');
|
||||
if (count($aChoice['modules']) === 0 && (!isset($aChoice['missing']) || $aChoice['missing'] === false)) {
|
||||
throw new Exception('Extension '.$aChoice['extension_code'].' does not have any module associated');
|
||||
}
|
||||
foreach ($aChoice['modules'] as $sModuleId) {
|
||||
$bSelected = true;
|
||||
|
||||
@@ -2,15 +2,13 @@
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Integration;
|
||||
|
||||
use Combodo\iTop\Application\WebPage\WebPage;
|
||||
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
use iTopExtension;
|
||||
use iTopExtensionsMap;
|
||||
use iTopExtensionsMapFake;
|
||||
use ModuleDiscovery;
|
||||
use WepPageFake;
|
||||
use WizardController;
|
||||
use WizStepModulesChoiceFake;
|
||||
use WepPageFake;
|
||||
use XMLParameters;
|
||||
|
||||
class WizStepModulesChoiceTest extends ItopTestCase
|
||||
@@ -930,6 +928,40 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
$this->oStep->GetSelectedModules($aStepInfo, ['_0' => '_0'], $aModules, '', '', $aExtensions);
|
||||
}
|
||||
|
||||
public function testGetSelectedModulesShouldNotThrowAnExceptionWhenAMandatoryModuleIsMissing()
|
||||
{
|
||||
$aExtensionsMapData = [];
|
||||
$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' => true,
|
||||
'source_label' => '',
|
||||
'uninstallable' => true,
|
||||
'missing' => true,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$aModules = [];
|
||||
$aExtensions = [];
|
||||
$this->oStep->GetSelectedModules($aStepInfo, ['_0' => '_0'], $aModules, '', '', $aExtensions);
|
||||
$this->assertCount(0, $aModules);
|
||||
$this->assertCount(1, $aExtensions);
|
||||
|
||||
}
|
||||
|
||||
public function ProviderDisplayOptions()
|
||||
{
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user