N°9567 - fix extension map init of installation choices

This commit is contained in:
odain
2026-05-11 16:36:30 +02:00
parent ed814c1439
commit e2d8db077d
9 changed files with 1332 additions and 26 deletions

View File

@@ -151,4 +151,31 @@ class ExtensionsMapTest extends ItopTestCase
$this->SetNonPublicProperty($oExtensionsMap, $mapKeyInItopExtensionMap, $aMap);
}
public function testiTopExtensionsMapInit()
{
$oiTopExtensionsMap = new iTopExtensionsMap(sAppRootForTests:__DIR__."/ressources");
//file_put_contents(__DIR__.'/ressources/all_extensions_from_datamodels.json', json_encode($this->SerializeExtensionMap($oiTopExtensionsMap), JSON_PRETTY_PRINT));
$sExpected = file_get_contents(__DIR__.'/ressources/all_extensions_from_datamodels.json');
$sExpected = str_replace('"sVersion": "ITOP_VERSION"', '"sVersion": "'.ITOP_VERSION.'"', $sExpected);
$this->assertEquals($sExpected, json_encode($this->SerializeExtensionMap($oiTopExtensionsMap), JSON_PRETTY_PRINT));
}
public function SerializeExtensionMap(iTopExtensionsMap $oiTopExtensionsMap): array
{
$aRes = [];
foreach ($oiTopExtensionsMap->GetAllExtensions() as $oExtension) {
$aRes[] = [
'sCode' => $oExtension->sCode,
'sSource' => $oExtension->sSource,
'sVersion' => $oExtension->sVersion,
'aModules' => $oExtension->aModules,
'aModuleVersion' => $oExtension->aModuleVersion,
'aModuleInfo' => $oExtension->aModuleInfo,
];
}
return $aRes;
}
}