N°9949 - Cannot uninstall IPAM from setup wizard screen (#1015)

* N°9949 - Cannot uninstall IPAM from setup wizard screen

* N°9949 - add test coverage

* N°9949 - handle list in compilation
This commit is contained in:
odain-cbd
2026-08-20 10:03:25 +02:00
committed by GitHub
parent cdd7bbedcb
commit 95cb21cff7
3 changed files with 57 additions and 4 deletions

View File

@@ -37,6 +37,40 @@ class ExtensionsMapTest extends ItopTestCase
$this->assertEquals($expected, array_keys($aExtensions));
}
public function testDeclareExtensionAsRemoved_WithDictPassed()
{
try {
$oExtensionsMap = $this->GiveExtensionMapWithAllTypeOfExtensions();
//non existing extension
$aExtensionCodes = ['unexisting_extension_code' => 'label_unexisting_extension_code'];
//extension ok
$aExtensionCodes ['installed_ext1'] = $oExtensionsMap->GetFromExtensionCode('installed_ext1')->sLabel;
//search extension by label ko
$sLabel = $oExtensionsMap->GetFromExtensionCode('installed_ext_in_package')->sLabel;
$aExtensionCodes [$sLabel] = $sLabel;
$oExtensionsMap->DeclareExtensionAsRemoved($aExtensionCodes);
$this->assertEquals(["installed_ext1"], ModuleDiscovery::GetRemovedExtensionCodes());
} finally {
ModuleDiscovery::DeclareRemovedExtensions([]);
}
}
public function testDeclareExtensionAsRemoved_WithListPassed()
{
try {
$oExtensionsMap = $this->GiveExtensionMapWithAllTypeOfExtensions();
$aExtensionCodes = ['unexisting_extension_code', 'installed_ext1'];
$aExtensionCodes [] = $oExtensionsMap->GetFromExtensionCode('installed_ext_in_package')->sLabel;
$oExtensionsMap->DeclareExtensionAsRemoved($aExtensionCodes);
$this->assertEquals(["installed_ext1"], ModuleDiscovery::GetRemovedExtensionCodes());
} finally {
ModuleDiscovery::DeclareRemovedExtensions([]);
}
}
public function testGetAllExtensionsToDisplayInSetup_WithExtensionsHavingDependencyIssues()
{
$oExtensionsMap = $this->GiveExtensionMapWithAllTypeOfExtensions();
@@ -137,6 +171,7 @@ class ExtensionsMapTest extends ItopTestCase
{
$oExt = new iTopExtension();
$oExt->sCode = $sCode;
$oExt->sLabel = "LABEL_".$sCode;
$oExt->sVersion = $sVersion;
$oExt->bVisible = $bVisible;
$oExt->sSource = $sSource;
@@ -147,6 +182,7 @@ class ExtensionsMapTest extends ItopTestCase
private function AddExtension(iTopExtensionsMap $oExtensionsMap, iTopExtension $oExt, string $mapKeyInItopExtensionMap)
{
$this->InvokeNonPublicMethod(iTopExtensionsMap::class, 'AddExtension', $oExtensionsMap, [$oExt]);
$aMap = $this->GetNonPublicProperty($oExtensionsMap, $mapKeyInItopExtensionMap);
$aMap[$oExt->sCode.'/'.$oExt->sVersion] = $oExt;
$this->SetNonPublicProperty($oExtensionsMap, $mapKeyInItopExtensionMap, $aMap);