mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Merge branch 'support/3.1' into support/3.2
This commit is contained in:
@@ -6,10 +6,17 @@ require_once(APPROOT.'/setup/wizardcontroller.class.inc.php');
|
||||
require_once(APPROOT.'/setup/wizardsteps.class.inc.php');
|
||||
|
||||
class InstallationFileService {
|
||||
/** @var \RunTimeEnvironment $oProductionEnv */
|
||||
private $oProductionEnv;
|
||||
|
||||
/** @var \ItopExtensionsMap $oProductionEnv */
|
||||
private $oItopExtensionsMap;
|
||||
|
||||
private $sTargetEnvironment;
|
||||
private $sInstallationPath;
|
||||
private $aSelectedModules;
|
||||
private $aSelectedExtensions;
|
||||
private $aAfterComputationSelectedExtensions;
|
||||
private $aUnSelectedModules;
|
||||
private $aAutoSelectModules;
|
||||
private $bInstallationOptionalChoicesChecked;
|
||||
@@ -18,7 +25,8 @@ class InstallationFileService {
|
||||
* @param string $sInstallationPath
|
||||
* @param string $sTargetEnvironment
|
||||
* @param array $aSelectedExtensions
|
||||
* @param bool $bInstallationOptionalChoicesChecked : this option is used only when no extensions are selected (ie empty $aSelectedExtensions)
|
||||
* @param bool $bInstallationOptionalChoicesChecked : this option is used only when no extensions are selected (ie empty
|
||||
* $aSelectedExtensions)
|
||||
*/
|
||||
public function __construct(string $sInstallationPath, string $sTargetEnvironment='production', array $aSelectedExtensions = [], bool $bInstallationOptionalChoicesChecked=true) {
|
||||
$this->sInstallationPath = $sInstallationPath;
|
||||
@@ -26,9 +34,49 @@ class InstallationFileService {
|
||||
$this->aUnSelectedModules = [];
|
||||
$this->sTargetEnvironment = $sTargetEnvironment;
|
||||
$this->aSelectedExtensions = $aSelectedExtensions;
|
||||
$this->aAfterComputationSelectedExtensions = (count($aSelectedExtensions)==0) ? [] : $aSelectedExtensions;
|
||||
$this->bInstallationOptionalChoicesChecked = $bInstallationOptionalChoicesChecked;
|
||||
}
|
||||
|
||||
public function Init(): void {
|
||||
clearstatcache();
|
||||
|
||||
$this->ProcessDefaultModules();
|
||||
$this->ProcessInstallationChoices();
|
||||
$this->ProcessExtensionModulesNotSpecifiedInChoices();
|
||||
$this->ProcessAutoSelectModules();
|
||||
}
|
||||
|
||||
public function GetProductionEnv(): RunTimeEnvironment {
|
||||
if (is_null($this->oProductionEnv)){
|
||||
$this->oProductionEnv = new RunTimeEnvironment();
|
||||
}
|
||||
return $this->oProductionEnv;
|
||||
}
|
||||
|
||||
public function SetProductionEnv(RunTimeEnvironment $oProductionEnv): void {
|
||||
$this->oProductionEnv = $oProductionEnv;
|
||||
}
|
||||
|
||||
public function GetAfterComputationSelectedExtensions(): array {
|
||||
return $this->aAfterComputationSelectedExtensions;
|
||||
}
|
||||
|
||||
public function SetItopExtensionsMap(ItopExtensionsMap $oItopExtensionsMap): void {
|
||||
$this->oItopExtensionsMap = $oItopExtensionsMap;
|
||||
}
|
||||
|
||||
public function GetItopExtensionsMap(): ItopExtensionsMap {
|
||||
if (is_null($this->oItopExtensionsMap)){
|
||||
$this->oItopExtensionsMap = new iTopExtensionsMap($this->sTargetEnvironment, true);
|
||||
}
|
||||
return $this->oItopExtensionsMap;
|
||||
}
|
||||
|
||||
public function GetAutoSelectModules(): array {
|
||||
return $this->aAutoSelectModules;
|
||||
}
|
||||
|
||||
public function GetSelectedModules(): array {
|
||||
return $this->aSelectedModules;
|
||||
}
|
||||
@@ -37,14 +85,6 @@ class InstallationFileService {
|
||||
return $this->aUnSelectedModules;
|
||||
}
|
||||
|
||||
public function Init(): void {
|
||||
clearstatcache();
|
||||
|
||||
$this->ProcessDefaultModules();
|
||||
$this->ProcessInstallationChoices();
|
||||
$this->ProcessAutoSelectModules();
|
||||
}
|
||||
|
||||
public function ProcessInstallationChoices(): void {
|
||||
$oXMLParameters = new XMLParameters($this->sInstallationPath);
|
||||
$aSteps = $oXMLParameters->Get('steps', []);
|
||||
@@ -120,10 +160,13 @@ class InstallationFileService {
|
||||
$sMandatory = $aChoiceInfo["mandatory"] ?? "false";
|
||||
|
||||
$aCurrentModules = $aChoiceInfo["modules"] ?? [];
|
||||
$sExtensionCode = $aChoiceInfo["extension_code"] ?? null;
|
||||
if (0 === count($this->aSelectedExtensions)){
|
||||
$bSelected = $bAllChecked || $sDefault === "true" || $sMandatory === "true";
|
||||
if ($bSelected){
|
||||
$this->aAfterComputationSelectedExtensions[]= $sExtensionCode;
|
||||
}
|
||||
} else {
|
||||
$sExtensionCode = $aChoiceInfo["extension_code"] ?? null;
|
||||
$bSelected = $sMandatory === "true" ||
|
||||
(null !== $sExtensionCode && in_array($sExtensionCode, $this->aSelectedExtensions));
|
||||
}
|
||||
@@ -198,8 +241,7 @@ class InstallationFileService {
|
||||
public function ProcessDefaultModules() : void {
|
||||
$sProductionModuleDir = APPROOT.'data/' . $this->sTargetEnvironment . '-modules/';
|
||||
|
||||
$oProductionEnv = new RunTimeEnvironment();
|
||||
$aAvailableModules = $oProductionEnv->AnalyzeInstallation(MetaModel::GetConfig(), $this->GetExtraDirs(), false, null);
|
||||
$aAvailableModules = $this->GetProductionEnv()->AnalyzeInstallation(MetaModel::GetConfig(), $this->GetExtraDirs(), false, null);
|
||||
|
||||
$this->aAutoSelectModules = [];
|
||||
foreach ($aAvailableModules as $sModuleId => $aModule) {
|
||||
@@ -213,7 +255,6 @@ class InstallationFileService {
|
||||
$this->aSelectedModules[$sModuleId] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
$bIsExtra = (array_key_exists('root_dir', $aModule) && (strpos($aModule['root_dir'],
|
||||
$sProductionModuleDir) !== false)); // Some modules (root, datamodel) have no 'root_dir'
|
||||
if ($bIsExtra) {
|
||||
@@ -225,7 +266,7 @@ class InstallationFileService {
|
||||
}
|
||||
|
||||
public function ProcessAutoSelectModules() : void {
|
||||
foreach($this->aAutoSelectModules as $sModuleId => $aModule)
|
||||
foreach($this->GetAutoSelectModules() as $sModuleId => $aModule)
|
||||
{
|
||||
try {
|
||||
$bSelected = false;
|
||||
@@ -241,4 +282,76 @@ class InstallationFileService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function CanChooseUnpackageExtension(iTopExtension $oExtension) : bool {
|
||||
if ($oExtension->sSource === iTopExtension::SOURCE_REMOTE){
|
||||
SetupLog::Info("Data Extension can be selected", null, ['extension' => $oExtension->sCode]);
|
||||
return true;
|
||||
}
|
||||
|
||||
$bSelectable = $this->bInstallationOptionalChoicesChecked && ($oExtension->sSource === iTopExtension::SOURCE_MANUAL);
|
||||
if ($bSelectable){
|
||||
SetupLog::Info("Manual Extension can be selected", null, ['extension' => $oExtension->sCode]);
|
||||
} else {
|
||||
SetupLog::Debug("Manual Extension can NOT be selected", null, ['extension' => $oExtension->sCode]);
|
||||
}
|
||||
|
||||
return $bSelectable;
|
||||
}
|
||||
|
||||
public function ProcessExtensionModulesNotSpecifiedInChoices() {
|
||||
/** @var \iTopExtension $oExtension */
|
||||
foreach($this->GetItopExtensionsMap()->GetAllExtensions() as $oExtension) {
|
||||
if (in_array($oExtension->sCode, $this->aAfterComputationSelectedExtensions)){
|
||||
//extension already processed in installation.xml
|
||||
SetupLog::Info("Extension already processed via installation choices", null,
|
||||
[
|
||||
'extension' => $oExtension->sCode,
|
||||
]) ;
|
||||
continue;
|
||||
}
|
||||
if ($this->CanChooseUnpackageExtension($oExtension)){
|
||||
if (($oExtension->bVisible) && (count($oExtension->aMissingDependencies) === 0)) {
|
||||
$aCurrentModules = [];
|
||||
$aUnselectableModules = [];
|
||||
$bIsExtensionSelectable = true;
|
||||
foreach ($oExtension->aModules as $sModuleId) {
|
||||
if (array_key_exists($sModuleId, $this->aSelectedModules)) {
|
||||
//already selected
|
||||
continue;
|
||||
}
|
||||
|
||||
if (array_key_exists($sModuleId, $this->aUnSelectedModules)) {
|
||||
$aUnselectableModules[] = $sModuleId;
|
||||
|
||||
//already unselected
|
||||
$bIsExtensionSelectable = false;
|
||||
} else {
|
||||
$aCurrentModules[$sModuleId] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($bIsExtensionSelectable) {
|
||||
SetupLog::Debug("Add modules from unpackaged extension", null,
|
||||
[
|
||||
'extension' => $oExtension->sCode,
|
||||
'source' => $oExtension->sSource,
|
||||
'modules to add' => array_keys($aCurrentModules),
|
||||
]);
|
||||
$this->aSelectedModules = array_merge($this->aSelectedModules, $aCurrentModules);
|
||||
$this->aAfterComputationSelectedExtensions[] = $oExtension->sCode;
|
||||
} else {
|
||||
SetupLog::Warning("Unpackaged extension can not be selected due to modules incompatible with installation choices",
|
||||
null,
|
||||
[
|
||||
'extension' => $oExtension->sCode,
|
||||
'source' => $oExtension->sSource,
|
||||
'modules' => array_keys($aCurrentModules),
|
||||
'unselectable modules' => $aUnselectableModules,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,8 @@ if (! is_null($sInstallationXmlPath) && is_file($sInstallationXmlPath)) {
|
||||
$sInstallationBaseName = basename($sInstallationXmlPath);
|
||||
|
||||
$aSelectedExtensionsFromXmlSetup = $oParams->Get('selected_extensions', []);
|
||||
if (count($aSelectedExtensionsFromXmlSetup) !== 0) {
|
||||
$bInstallationChoicesProvided = count($aSelectedExtensionsFromXmlSetup) !== 0;
|
||||
if ($bInstallationChoicesProvided) {
|
||||
$sMsg = "Modules to install computed based on $sInstallationBaseName file and installation choices (listed in section `selected_extensions` of $sXmlSetupBaseName file)";
|
||||
echo "$sMsg:\n".implode(',', $aSelectedExtensionsFromXmlSetup)."\n\n";
|
||||
SetupLog::Info($sMsg, null, $aSelectedExtensionsFromXmlSetup);
|
||||
@@ -75,11 +76,21 @@ if (! is_null($sInstallationXmlPath) && is_file($sInstallationXmlPath)) {
|
||||
|
||||
$oInstallationFileService = new InstallationFileService($sInstallationXmlPath, $sTargetEnvironment, $aSelectedExtensionsFromXmlSetup);
|
||||
$oInstallationFileService->Init();
|
||||
|
||||
$aComputedExtensions = $oInstallationFileService->GetAfterComputationSelectedExtensions();
|
||||
if (! $bInstallationChoicesProvided) {
|
||||
$sMsg = "Computed installation choices";
|
||||
echo "$sMsg:\n".implode(',', $aComputedExtensions)."\n\n";
|
||||
SetupLog::Info($sMsg, null, $aComputedExtensions);
|
||||
}
|
||||
$aSelectedExtensions = array_keys($aComputedExtensions);
|
||||
$oParams->Set('selected_extensions', $aSelectedExtensions);
|
||||
|
||||
$aComputedModules = $oInstallationFileService->GetSelectedModules();
|
||||
$aSelectedModules = array_keys($aComputedModules);
|
||||
$oParams->Set('selected_modules', $aSelectedModules);
|
||||
|
||||
$sMsg = "Modules to install computed";
|
||||
$sMsg = "Computed modules to install";
|
||||
} else {
|
||||
$aSelectedModules = $oParams->Get('selected_modules', []);
|
||||
$sMsg = "Modules to install listed in $sXmlSetupBaseName (selected_modules section)";
|
||||
|
||||
@@ -2,31 +2,133 @@
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Setup\UnattendedInstall;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
use ItopExtensionsMap;
|
||||
use iTopExtension;
|
||||
use RunTimeEnvironment;
|
||||
use InstallationFileService;
|
||||
use ModuleDiscovery;
|
||||
|
||||
/**
|
||||
* @group itop-clone-only
|
||||
*/
|
||||
class InstallationFileServiceTest extends TestCase {
|
||||
class InstallationFileServiceTest extends ItopTestCase {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
require_once(dirname(__FILE__, 6) . '/setup/unattended-install/InstallationFileService.php');
|
||||
$this->sFolderToCleanup = null;
|
||||
\ModuleDiscovery::ResetCache();
|
||||
|
||||
$this->RequireOnceItopFile('/setup/unattended-install/InstallationFileService.php');
|
||||
ModuleDiscovery::ResetCache();
|
||||
}
|
||||
|
||||
protected function tearDown(): void {
|
||||
parent::tearDown();
|
||||
|
||||
$sModuleId = "itop-problem-mgmt";
|
||||
$this->RecurseMoveDir(APPROOT."data/production-modules/$sModuleId", APPROOT . "datamodels/2.x/$sModuleId");
|
||||
}
|
||||
|
||||
private function GetInstallationPath() {
|
||||
return realpath(__DIR__ . '/installation.xml');
|
||||
private function GetInstallationPath() : string {
|
||||
return realpath(__DIR__ . '/resources/installation.xml');
|
||||
}
|
||||
|
||||
public function GetDefaultModulesProvider() {
|
||||
private function GetModuleData($sCategory, bool $bIsVisible, bool $bIsAutoSelect, bool $bProductionModulesInRootDir=false) : array {
|
||||
$sRootDir = str_replace('//', '/', $bProductionModulesInRootDir ? $this->GetAppRoot() .'data/production-modules/' : '');
|
||||
|
||||
var_dump($sRootDir);
|
||||
|
||||
$aModuleData = [
|
||||
'category' => $sCategory,
|
||||
'visible' => $bIsVisible,
|
||||
'root_dir' => $sRootDir,
|
||||
];
|
||||
|
||||
if ($bIsAutoSelect){
|
||||
$aModuleData['auto_select'] = true;
|
||||
}
|
||||
|
||||
return $aModuleData;
|
||||
}
|
||||
|
||||
public function ProcessDefaultModulesProvider() {
|
||||
return [
|
||||
'root module' => [
|
||||
'aAllFoundModules' => [
|
||||
'_Root_' => $this->GetModuleData('authentication', false, false, true),
|
||||
],
|
||||
'aExpectedSelectedModules' => [],
|
||||
'aExpectedAutoSelectModules' => [],
|
||||
],
|
||||
'auto-select root module' => [
|
||||
'aAllFoundModules' => [
|
||||
'_Root_' => $this->GetModuleData('authentication', false, true, true),
|
||||
],
|
||||
'aExpectedSelectedModules' => [],
|
||||
'aExpectedAutoSelectModules' => [],
|
||||
],
|
||||
'autoselect module only' => [
|
||||
'aAllFoundModules' => [
|
||||
'autoselect-only' => $this->GetModuleData('mycategory', true, true),
|
||||
],
|
||||
'aExpectedSelectedModules' => [],
|
||||
'aExpectedAutoSelectModules' => ['autoselect-only'],
|
||||
],
|
||||
'autoselect/invisible module' => [
|
||||
'aAllFoundModules' => [
|
||||
'autoselect-only' => $this->GetModuleData('mycategory', false, true),
|
||||
],
|
||||
'aExpectedSelectedModules' => [],
|
||||
'aExpectedAutoSelectModules' => ['autoselect-only'],
|
||||
],
|
||||
'autoselect/invisible/in-root-dir module' => [
|
||||
'aAllFoundModules' => [
|
||||
'autoselect-only' => $this->GetModuleData('mycategory', false, true , true),
|
||||
],
|
||||
'aExpectedSelectedModules' => [],
|
||||
'aExpectedAutoSelectModules' => ['autoselect-only'],
|
||||
],
|
||||
'visible/authent module' => [
|
||||
'aAllFoundModules' => [
|
||||
'authent-module' => $this->GetModuleData('authentication', true, false , false),
|
||||
],
|
||||
'aExpectedSelectedModules' => ['authent-module'],
|
||||
'aExpectedAutoSelectModules' => [],
|
||||
],
|
||||
'invisible module' => [
|
||||
'aAllFoundModules' => [
|
||||
'visible-module' => $this->GetModuleData('mycategory', false, false , false),
|
||||
],
|
||||
'aExpectedSelectedModules' => ['visible-module'],
|
||||
'aExpectedAutoSelectModules' => [],
|
||||
],
|
||||
'in-root-dir module' => [
|
||||
'aAllFoundModules' => [
|
||||
'in-root-dir-module' => $this->GetModuleData('mycategory', true, false , true),
|
||||
],
|
||||
'aExpectedSelectedModules' => ['in-root-dir-module'],
|
||||
'aExpectedAutoSelectModules' => [],
|
||||
],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @dataProvider ProcessDefaultModulesProvider
|
||||
*/
|
||||
public function testProcessDefaultModules(array $aAllFoundModules, array $aExpectedSelectedModules, array $aExpectedAutoSelectModules) {
|
||||
$oInstallationFileService = new InstallationFileService('', 'production', [], true);
|
||||
|
||||
$oProductionEnv = $this->createMock(RunTimeEnvironment::class);
|
||||
$oProductionEnv->expects($this->once())
|
||||
->method('AnalyzeInstallation')
|
||||
->willReturn($aAllFoundModules);
|
||||
|
||||
$oInstallationFileService->SetProductionEnv($oProductionEnv);
|
||||
$oInstallationFileService->ProcessDefaultModules();
|
||||
|
||||
sort($aExpectedSelectedModules);
|
||||
$aModules = array_keys($oInstallationFileService->GetSelectedModules());
|
||||
sort($aModules);
|
||||
|
||||
$this->assertEquals($aExpectedSelectedModules, $aModules);
|
||||
|
||||
$aAutoSelectModules = array_keys($oInstallationFileService->GetAutoSelectModules());
|
||||
sort($aAutoSelectModules);
|
||||
$this->assertEquals($aExpectedAutoSelectModules, $aAutoSelectModules);
|
||||
}
|
||||
|
||||
public function ProcessInstallationChoicesProvider() {
|
||||
return [
|
||||
'all checked' => [ true ],
|
||||
'only defaut + mandatory' => [ false ],
|
||||
@@ -34,12 +136,16 @@ class InstallationFileServiceTest extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider GetDefaultModulesProvider
|
||||
* @dataProvider ProcessInstallationChoicesProvider
|
||||
*/
|
||||
public function testProcessInstallationChoices($bInstallationOptionalChoicesChecked=false) {
|
||||
$sPath = realpath($this->GetInstallationPath());
|
||||
$this->assertTrue(is_file($sPath));
|
||||
$oInstallationFileService = new \InstallationFileService($sPath, 'production', [], $bInstallationOptionalChoicesChecked);
|
||||
public function testProcessInstallationChoices($bInstallationOptionalChoicesChecked) {
|
||||
$sPath = $this->GetInstallationPath();
|
||||
$oInstallationFileService = new InstallationFileService($sPath, 'production', [], $bInstallationOptionalChoicesChecked);
|
||||
$oProductionEnv = $this->createMock(RunTimeEnvironment::class);
|
||||
$oProductionEnv->expects($this->never())
|
||||
->method('AnalyzeInstallation');
|
||||
$oInstallationFileService->SetProductionEnv($oProductionEnv);
|
||||
|
||||
$oInstallationFileService->ProcessInstallationChoices();
|
||||
$aExpectedModules = [
|
||||
"itop-config-mgmt",
|
||||
@@ -88,23 +194,127 @@ class InstallationFileServiceTest extends TestCase {
|
||||
sort($aExpectedUnselectedModules);
|
||||
sort($aUnselectedModules);
|
||||
$this->assertEquals($aExpectedUnselectedModules, $aUnselectedModules);
|
||||
|
||||
$aGetAfterComputationSelectedExtensions = $oInstallationFileService->GetAfterComputationSelectedExtensions();
|
||||
sort($aGetAfterComputationSelectedExtensions);
|
||||
$aExpectedExtensions = [
|
||||
'itop-change-mgmt-simple',
|
||||
'itop-config-mgmt-core',
|
||||
'itop-config-mgmt-datacenter',
|
||||
'itop-config-mgmt-end-user',
|
||||
'itop-config-mgmt-storage',
|
||||
'itop-config-mgmt-virtualization',
|
||||
'itop-service-mgmt-enterprise',
|
||||
'itop-ticket-mgmt-simple-ticket',
|
||||
'itop-ticket-mgmt-simple-ticket-enhanced-portal',
|
||||
];
|
||||
if ($bInstallationOptionalChoicesChecked){
|
||||
$aExpectedExtensions []= "itop-problem-mgmt";
|
||||
$aExpectedExtensions []= 'itop-kown-error-mgmt';
|
||||
}
|
||||
sort($aExpectedExtensions);
|
||||
$this->assertEquals($aExpectedExtensions, $aGetAfterComputationSelectedExtensions);
|
||||
|
||||
$this->ValidateNonItilExtensionComputation($oInstallationFileService, $bInstallationOptionalChoicesChecked);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ItilExtensionProvider
|
||||
*/
|
||||
public function testProcessInstallationChoicesWithItilChoices(array $aSelectedExtensions, bool $bKnownMgtSelected, bool $bCoreMgtSelected) {
|
||||
$sPath = $this->GetInstallationPath();
|
||||
$oInstallationFileService = new InstallationFileService($sPath, 'production', $aSelectedExtensions, false);
|
||||
$oProductionEnv = $this->createMock(RunTimeEnvironment::class);
|
||||
$oProductionEnv->expects($this->never())
|
||||
->method('AnalyzeInstallation');
|
||||
$oInstallationFileService->SetProductionEnv($oProductionEnv);
|
||||
|
||||
$oInstallationFileService->ProcessInstallationChoices();
|
||||
|
||||
$aExpectedInstallationModules = [
|
||||
"itop-config-mgmt",
|
||||
"itop-attachments",
|
||||
"itop-profiles-itil",
|
||||
"itop-welcome-itil",
|
||||
"itop-tickets",
|
||||
"itop-files-information",
|
||||
"combodo-db-tools",
|
||||
"itop-core-update",
|
||||
"itop-hub-connector",
|
||||
"itop-oauth-client",
|
||||
"itop-datacenter-mgmt",
|
||||
"itop-endusers-devices",
|
||||
"itop-storage-mgmt",
|
||||
"itop-virtualization-mgmt",
|
||||
"itop-service-mgmt",
|
||||
"itop-request-mgmt-itil",
|
||||
"itop-incident-mgmt-itil",
|
||||
"itop-portal",
|
||||
"itop-portal-base",
|
||||
"itop-change-mgmt-itil",
|
||||
];
|
||||
if ($bKnownMgtSelected){
|
||||
$aExpectedInstallationModules []= "itop-knownerror-mgmt";
|
||||
}
|
||||
|
||||
sort($aExpectedInstallationModules);
|
||||
$aModules = array_keys($oInstallationFileService->GetSelectedModules());
|
||||
sort($aModules);
|
||||
|
||||
$this->assertEquals($aExpectedInstallationModules, $aModules);
|
||||
|
||||
$aExpectedUnselectedModules = [
|
||||
'itop-change-mgmt',
|
||||
'itop-problem-mgmt',
|
||||
'itop-request-mgmt',
|
||||
'itop-service-mgmt-provider',
|
||||
];
|
||||
if (!$bKnownMgtSelected){
|
||||
$aExpectedUnselectedModules[]='itop-knownerror-mgmt';
|
||||
}
|
||||
$aUnselectedModules = array_keys($oInstallationFileService->GetUnSelectedModules());
|
||||
sort($aExpectedUnselectedModules);
|
||||
sort($aUnselectedModules);
|
||||
$this->assertEquals($aExpectedUnselectedModules, $aUnselectedModules);
|
||||
|
||||
$this->ValidateItilExtensionComputation($oInstallationFileService, $bKnownMgtSelected, $bCoreMgtSelected);
|
||||
}
|
||||
|
||||
public function GetDefaultModulesProvider() {
|
||||
return [
|
||||
'check all possible modules' => [true],
|
||||
'only minimum defaul/mandatory from installation.xml' => [false],
|
||||
];
|
||||
}
|
||||
|
||||
private function GetMockListOfFoundModules() : array {
|
||||
$sJsonContent = file_get_contents(realpath(__DIR__ . '/resources/AnalyzeInstallation.json'));
|
||||
$sJsonContent = str_replace('ROOTDIR_TOREPLACE', APPROOT, $sJsonContent);
|
||||
return json_decode($sJsonContent, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider GetDefaultModulesProvider
|
||||
*/
|
||||
public function testGetAllSelectedModules($bInstallationOptionalChoicesChecked=false) {
|
||||
$sPath = realpath($this->GetInstallationPath());
|
||||
$oInstallationFileService = new \InstallationFileService($sPath, 'production', [], $bInstallationOptionalChoicesChecked);
|
||||
$sPath = $this->GetInstallationPath();
|
||||
$oInstallationFileService = new InstallationFileService($sPath, 'production', [], $bInstallationOptionalChoicesChecked);
|
||||
|
||||
$oProductionEnv = $this->createMock(RunTimeEnvironment::class);
|
||||
$oProductionEnv->expects($this->once())
|
||||
->method('AnalyzeInstallation')
|
||||
->willReturn($this->GetMockListOfFoundModules());
|
||||
$oInstallationFileService->SetProductionEnv($oProductionEnv);
|
||||
|
||||
$oItopExtensionsMap = $this->createMock(ItopExtensionsMap::class);
|
||||
$oItopExtensionsMap->expects($this->once())
|
||||
->method('GetAllExtensions')
|
||||
->willReturn([]);
|
||||
$oInstallationFileService->SetItopExtensionsMap($oItopExtensionsMap);
|
||||
|
||||
$oInstallationFileService->Init();
|
||||
|
||||
$aSelectedModules = $oInstallationFileService->GetSelectedModules();
|
||||
$aExpectedInstallationModules = [
|
||||
'combodo-backoffice-darkmoon-theme',
|
||||
'combodo-backoffice-fullmoon-high-contrast-theme',
|
||||
'combodo-backoffice-fullmoon-protanopia-deuteranopia-theme',
|
||||
'combodo-backoffice-fullmoon-tritanopia-theme',
|
||||
'itop-structure',
|
||||
"itop-config-mgmt",
|
||||
"itop-attachments",
|
||||
"itop-profiles-itil",
|
||||
@@ -124,40 +334,75 @@ class InstallationFileServiceTest extends TestCase {
|
||||
"itop-portal",
|
||||
"itop-portal-base",
|
||||
"itop-change-mgmt",
|
||||
'authent-cas',
|
||||
'authent-external',
|
||||
'authent-ldap',
|
||||
'authent-local',
|
||||
'itop-backup',
|
||||
'itop-config',
|
||||
'itop-sla-computation',
|
||||
'itop-bridge-virtualization-storage',
|
||||
];
|
||||
|
||||
if ($bInstallationOptionalChoicesChecked){
|
||||
$aExpectedInstallationModules []= "itop-problem-mgmt";
|
||||
$aExpectedInstallationModules []= "itop-knownerror-mgmt";
|
||||
}
|
||||
|
||||
$aExpectedAuthenticationModules = [
|
||||
'authent-cas',
|
||||
'authent-external',
|
||||
'authent-ldap',
|
||||
'authent-local',
|
||||
];
|
||||
sort($aExpectedInstallationModules);
|
||||
|
||||
$aUnvisibleModules = [
|
||||
'itop-backup',
|
||||
'itop-config',
|
||||
'itop-sla-computation',
|
||||
];
|
||||
$aSelectedModules = array_keys($oInstallationFileService->GetSelectedModules());
|
||||
sort($aSelectedModules);
|
||||
$this->assertEquals($aExpectedInstallationModules, $aSelectedModules);
|
||||
|
||||
$aAutoSelectedModules = [
|
||||
'itop-bridge-cmdb-services',
|
||||
'itop-bridge-virtualization-storage',
|
||||
'itop-bridge-cmdb-ticket',
|
||||
'itop-bridge-datacenter-mgmt-services',
|
||||
'itop-bridge-endusers-devices-services',
|
||||
'itop-bridge-storage-mgmt-services',
|
||||
'itop-bridge-virtualization-mgmt-services',
|
||||
];
|
||||
$this->ValidateNonItilExtensionComputation($oInstallationFileService, $bInstallationOptionalChoicesChecked);
|
||||
}
|
||||
|
||||
$this->checkModuleList("installation.xml choices", $aExpectedInstallationModules, $aSelectedModules);
|
||||
$this->checkModuleList("authentication category", $aExpectedAuthenticationModules, $aSelectedModules);
|
||||
$this->checkModuleList("unvisible", $aUnvisibleModules, $aSelectedModules);
|
||||
$this->checkModuleList("auto-select", $aAutoSelectedModules, $aSelectedModules);
|
||||
$this->assertEquals([], $aSelectedModules, "there should be no more modules remaining apart from below lists");
|
||||
private function ValidateNonItilExtensionComputation($oInstallationFileService, bool $bInstallationOptionalChoicesChecked, array $aAdditionalExtensions=[]) {
|
||||
$aGetAfterComputationSelectedExtensions = $oInstallationFileService->GetAfterComputationSelectedExtensions();
|
||||
sort($aGetAfterComputationSelectedExtensions);
|
||||
$aExpectedExtensions = array_merge($aAdditionalExtensions, [
|
||||
'itop-change-mgmt-simple',
|
||||
'itop-config-mgmt-core',
|
||||
'itop-config-mgmt-datacenter',
|
||||
'itop-config-mgmt-end-user',
|
||||
'itop-config-mgmt-storage',
|
||||
'itop-config-mgmt-virtualization',
|
||||
'itop-service-mgmt-enterprise',
|
||||
'itop-ticket-mgmt-simple-ticket',
|
||||
'itop-ticket-mgmt-simple-ticket-enhanced-portal',
|
||||
]);
|
||||
if ($bInstallationOptionalChoicesChecked){
|
||||
$aExpectedExtensions []= "itop-problem-mgmt";
|
||||
$aExpectedExtensions []= 'itop-kown-error-mgmt';
|
||||
}
|
||||
sort($aExpectedExtensions);
|
||||
$this->assertEquals($aExpectedExtensions, $aGetAfterComputationSelectedExtensions);
|
||||
}
|
||||
|
||||
private function ValidateItilExtensionComputation($oInstallationFileService, bool $bKnownMgtSelected, bool $bCoreMgtSelected) {
|
||||
$aGetAfterComputationSelectedExtensions = $oInstallationFileService->GetAfterComputationSelectedExtensions();
|
||||
sort($aGetAfterComputationSelectedExtensions);
|
||||
$aExpectedExtensions = [
|
||||
'itop-change-mgmt-itil',
|
||||
'itop-config-mgmt-datacenter',
|
||||
'itop-config-mgmt-end-user',
|
||||
'itop-config-mgmt-storage',
|
||||
'itop-config-mgmt-virtualization',
|
||||
'itop-service-mgmt-enterprise',
|
||||
'itop-ticket-mgmt-itil',
|
||||
'itop-ticket-mgmt-itil-enhanced-portal',
|
||||
'itop-ticket-mgmt-itil-incident',
|
||||
'itop-ticket-mgmt-itil-user-request',
|
||||
];
|
||||
if ($bCoreMgtSelected){
|
||||
$aExpectedExtensions []= 'itop-config-mgmt-core';
|
||||
}
|
||||
if ($bKnownMgtSelected){
|
||||
$aExpectedExtensions []= 'itop-kown-error-mgmt';
|
||||
}
|
||||
sort($aExpectedExtensions);
|
||||
$this->assertEquals($aExpectedExtensions, $aGetAfterComputationSelectedExtensions);
|
||||
}
|
||||
|
||||
private function GetSelectedItilExtensions(bool $coreExtensionIncluded, bool $bKnownMgtIncluded) : array {
|
||||
@@ -191,18 +436,22 @@ class InstallationFileServiceTest extends TestCase {
|
||||
'all itil extensions + INCLUDING known-error-mgt' => [
|
||||
'aSelectedExtensions' => $this->GetSelectedItilExtensions(true, true),
|
||||
'bKnownMgtSelected' => true,
|
||||
'bCoreMgtSelected' => true,
|
||||
],
|
||||
'all itil extensions WITHOUT known-error-mgt' => [
|
||||
'aSelectedExtensions' => $this->GetSelectedItilExtensions(true, false),
|
||||
'bKnownMgtSelected' => false,
|
||||
'bCoreMgtSelected' => true,
|
||||
],
|
||||
'all itil extensions WITHOUT core mandatory ones + INCLUDING known-error-mgt' => [
|
||||
'aSelectedExtensions' => $this->GetSelectedItilExtensions(false, true),
|
||||
'bKnownMgtSelected' => true,
|
||||
'bCoreMgtSelected' => false,
|
||||
],
|
||||
'all itil extensions WITHOUT core mandatory ones and WITHOUT known-error-mgt' => [
|
||||
'aSelectedExtensions' => $this->GetSelectedItilExtensions(false, false),
|
||||
'bKnownMgtSelected' => false,
|
||||
'bCoreMgtSelected' => false,
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -210,18 +459,26 @@ class InstallationFileServiceTest extends TestCase {
|
||||
/**
|
||||
* @dataProvider ItilExtensionProvider
|
||||
*/
|
||||
public function testGetAllSelectedModules_withItilExtensions(array $aSelectedExtensions, bool $bKnownMgtSelected) {
|
||||
$sPath = realpath($this->GetInstallationPath());
|
||||
$oInstallationFileService = new \InstallationFileService($sPath, 'production', $aSelectedExtensions);
|
||||
public function testGetAllSelectedModules_withItilExtensions(array $aSelectedExtensions, bool $bKnownMgtSelected, bool $bCoreMgtSelected) {
|
||||
$sPath = $this->GetInstallationPath();
|
||||
$oInstallationFileService = new InstallationFileService($sPath, 'production', $aSelectedExtensions);
|
||||
|
||||
$oProductionEnv = $this->createMock(RunTimeEnvironment::class);
|
||||
$oProductionEnv->expects($this->once())
|
||||
->method('AnalyzeInstallation')
|
||||
->willReturn($this->GetMockListOfFoundModules());
|
||||
$oInstallationFileService->SetProductionEnv($oProductionEnv);
|
||||
|
||||
$oItopExtensionsMap = $this->createMock(ItopExtensionsMap::class);
|
||||
$oItopExtensionsMap->expects($this->once())
|
||||
->method('GetAllExtensions')
|
||||
->willReturn([]);
|
||||
$oInstallationFileService->SetItopExtensionsMap($oItopExtensionsMap);
|
||||
|
||||
$oInstallationFileService->Init();
|
||||
|
||||
$aSelectedModules = $oInstallationFileService->GetSelectedModules();
|
||||
$aSelectedModules = array_keys($oInstallationFileService->GetSelectedModules());
|
||||
$aExpectedInstallationModules = [
|
||||
'combodo-backoffice-darkmoon-theme',
|
||||
'combodo-backoffice-fullmoon-high-contrast-theme',
|
||||
'combodo-backoffice-fullmoon-protanopia-deuteranopia-theme',
|
||||
'combodo-backoffice-fullmoon-tritanopia-theme',
|
||||
'itop-structure',
|
||||
"itop-config-mgmt",
|
||||
"itop-attachments",
|
||||
"itop-profiles-itil",
|
||||
@@ -243,102 +500,247 @@ class InstallationFileServiceTest extends TestCase {
|
||||
"itop-portal-base",
|
||||
"itop-change-mgmt-itil",
|
||||
"itop-full-itil",
|
||||
'authent-cas',
|
||||
'authent-external',
|
||||
'authent-ldap',
|
||||
'authent-local',
|
||||
'itop-backup',
|
||||
'itop-config',
|
||||
'itop-sla-computation',
|
||||
'itop-bridge-virtualization-storage',
|
||||
];
|
||||
if ($bKnownMgtSelected){
|
||||
$aExpectedInstallationModules []= "itop-knownerror-mgmt";
|
||||
}
|
||||
|
||||
$aExpectedAuthenticationModules = [
|
||||
'authent-cas',
|
||||
'authent-external',
|
||||
'authent-ldap',
|
||||
'authent-local',
|
||||
];
|
||||
sort($aExpectedInstallationModules);
|
||||
sort($aSelectedModules);
|
||||
$this->assertEquals($aExpectedInstallationModules, $aSelectedModules);
|
||||
|
||||
$aUnvisibleModules = [
|
||||
'itop-backup',
|
||||
'itop-config',
|
||||
'itop-sla-computation',
|
||||
];
|
||||
|
||||
$aAutoSelectedModules = [
|
||||
'itop-bridge-cmdb-services',
|
||||
'itop-bridge-virtualization-storage',
|
||||
'itop-bridge-cmdb-ticket',
|
||||
'itop-bridge-datacenter-mgmt-services',
|
||||
'itop-bridge-endusers-devices-services',
|
||||
'itop-bridge-storage-mgmt-services',
|
||||
'itop-bridge-virtualization-mgmt-services',
|
||||
];
|
||||
|
||||
$this->checkModuleList("installation.xml choices", $aExpectedInstallationModules, $aSelectedModules);
|
||||
$this->checkModuleList("authentication category", $aExpectedAuthenticationModules, $aSelectedModules);
|
||||
$this->checkModuleList("unvisible", $aUnvisibleModules, $aSelectedModules);
|
||||
$this->checkModuleList("auto-select", $aAutoSelectedModules, $aSelectedModules);
|
||||
$this->assertEquals([], $aSelectedModules, "there should be no more modules remaining apart from below lists");
|
||||
$this->ValidateItilExtensionComputation($oInstallationFileService, $bKnownMgtSelected, $bCoreMgtSelected);
|
||||
}
|
||||
|
||||
private function checkModuleList(string $sModuleCategory, array $aExpectedModuleList, array &$aSelectedModules) {
|
||||
$aMissingModules = [];
|
||||
|
||||
foreach ($aExpectedModuleList as $sModuleId){
|
||||
if (! array_key_exists($sModuleId, $aSelectedModules)){
|
||||
$aMissingModules[]=$sModuleId;
|
||||
} else {
|
||||
unset($aSelectedModules[$sModuleId]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEquals([], $aMissingModules, "$sModuleCategory modules are missing");
|
||||
|
||||
private function CreateItopExtension(string $sSource, string $sCode, array $aModules, array $aMissingDependencies, bool $bIsVisible) : iTopExtension{
|
||||
$oExtension = new iTopExtension();
|
||||
$oExtension->sCode = $sCode;
|
||||
$oExtension->sSource = $sSource;
|
||||
$oExtension->aModules = $aModules;
|
||||
$oExtension->aMissingDependencies = $aMissingDependencies;
|
||||
$oExtension->bVisible = $bIsVisible;
|
||||
return $oExtension;
|
||||
}
|
||||
|
||||
public function ProductionModulesProvider() {
|
||||
public function CanChooseUnpackageExtensionProvider() {
|
||||
return [
|
||||
'module autoload as located in production-modules' => [ true ],
|
||||
'module not loaded' => [ false ],
|
||||
'extension in SOURCE_REMOTE' => [
|
||||
'sCode' => "extension-from-designer",
|
||||
'bInstallationOptionalChoicesChecked' => false,
|
||||
'sSource' => 'data',
|
||||
'bExpectedRes' => true
|
||||
],
|
||||
'extension in SOURCE_WIZARD' => [
|
||||
'sCode' => 'extension-from-package',
|
||||
'bInstallationOptionalChoicesChecked' => true,
|
||||
'sSource' => 'datamodels',
|
||||
'bExpectedRes' => false
|
||||
],
|
||||
'extension in SOURCE_MANUAL + optional OK' => [
|
||||
'sCode' => 'extension-from-package',
|
||||
'bInstallationOptionalChoicesChecked' => true,
|
||||
'sSource' => 'extensions',
|
||||
'bExpectedRes' => true
|
||||
],
|
||||
'extension in SOURCE_MANUAL + optional NOT OK' => [
|
||||
'sCode' => 'extension-from-package',
|
||||
'bInstallationOptionalChoicesChecked' => false,
|
||||
'sSource' => 'extensions',
|
||||
'bExpectedRes' => false
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ProductionModulesProvider
|
||||
* @dataProvider CanChooseUnpackageExtensionProvider
|
||||
*/
|
||||
public function testGetAllSelectedModules_ProductionModules(bool $bModuleInProductionModulesFolder) {
|
||||
$sModuleId = "itop-problem-mgmt";
|
||||
if ($bModuleInProductionModulesFolder){
|
||||
if (! is_dir(APPROOT."data/production-modules")){
|
||||
@mkdir(APPROOT."data/production-modules");
|
||||
}
|
||||
public function testCanChooseUnpackageExtension(string $sCode, bool $bInstallationOptionalChoicesChecked, string $sSource, bool $bExpectedRes) {
|
||||
$sPath = $this->GetInstallationPath();
|
||||
$oInstallationFileService = new InstallationFileService($sPath, 'production', [], $bInstallationOptionalChoicesChecked);
|
||||
|
||||
$this->RecurseMoveDir(APPROOT . "datamodels/2.x/$sModuleId", APPROOT."data/production-modules/$sModuleId");
|
||||
$oItopExtension = $this->CreateItopExtension($sSource, $sCode, [], [], true);
|
||||
$this->assertEquals($bExpectedRes, $oInstallationFileService->CanChooseUnpackageExtension($oItopExtension));
|
||||
}
|
||||
|
||||
public function ProcessExtensionModulesNotSpecifiedInChoicesProvider() {
|
||||
return [
|
||||
'extensions to install OK' => [
|
||||
'aExtensionData' => [
|
||||
'extension1' => [
|
||||
//'itop-request-mgmt-itil', //unselected
|
||||
'combodo-monitoring',
|
||||
'itop-config-mgmt', //already selected
|
||||
],
|
||||
'extension2' => [
|
||||
//'itop-incident-mgmt-itil', //unselected
|
||||
'combodo-monitoring2',
|
||||
'itop-attachments', //already selected
|
||||
]
|
||||
],
|
||||
'bExtensionCanBeChoosen' => true,
|
||||
'aMissingDependencies' => [],
|
||||
'bIsVisible' => true,
|
||||
'bExpectedAdditionalExtensions' => [
|
||||
'extension1', 'extension2'
|
||||
],
|
||||
'bExpectedAdditionalModules' => [
|
||||
'combodo-monitoring', 'combodo-monitoring2'
|
||||
]
|
||||
],
|
||||
'extensions to install cannot be choose,' => [
|
||||
'aExtensionData' => [
|
||||
'extension1' => [
|
||||
'combodo-monitoring',
|
||||
],
|
||||
'extension2' => [
|
||||
'combodo-monitoring2',
|
||||
]
|
||||
],
|
||||
'bExtensionCanBeChoosen' => false,
|
||||
'aMissingDependencies' => [],
|
||||
'bIsVisible' => true,
|
||||
'bExpectedAdditionalExtensions' => [],
|
||||
'bExpectedAdditionalModules' => []
|
||||
],
|
||||
'extensions to install not visible' => [
|
||||
'aExtensionData' => [
|
||||
'extension1' => [
|
||||
'combodo-monitoring',
|
||||
],
|
||||
'extension2' => [
|
||||
'combodo-monitoring2',
|
||||
]
|
||||
],
|
||||
'bExtensionCanBeChoosen' => true,
|
||||
'aMissingDependencies' => [],
|
||||
'bIsVisible' => false,
|
||||
'bExpectedAdditionalExtensions' => [],
|
||||
'bExpectedAdditionalModules' => []
|
||||
],
|
||||
'extensions to install with missing dependencies' => [
|
||||
'aExtensionData' => [
|
||||
'extension1' => [
|
||||
'combodo-monitoring',
|
||||
],
|
||||
'extension2' => [
|
||||
'combodo-monitoring2',
|
||||
]
|
||||
],
|
||||
'bExtensionCanBeChoosen' => true,
|
||||
'aMissingDependencies' => ['missing-module'],
|
||||
'bIsVisible' => true,
|
||||
'bExpectedAdditionalExtensions' => [],
|
||||
'bExpectedAdditionalModules' => []
|
||||
],
|
||||
'extensions to install with unselectable ITIL module' => [
|
||||
'aExtensionData' => [
|
||||
'extension1' => [
|
||||
'itop-request-mgmt-itil', //unselected
|
||||
'combodo-monitoring',
|
||||
],
|
||||
'extension2' => [
|
||||
'itop-incident-mgmt-itil', //unselected
|
||||
'combodo-monitoring2',
|
||||
]
|
||||
],
|
||||
'bExtensionCanBeChoosen' => true,
|
||||
'aMissingDependencies' => [],
|
||||
'bIsVisible' => true,
|
||||
'bExpectedAdditionalExtensions' => [],
|
||||
'bExpectedAdditionalModules' => []
|
||||
],
|
||||
'extensions already processed' => [
|
||||
'aExtensionData' => [
|
||||
'itop-config-mgmt-core' => [
|
||||
'itop-config-mgmt', //already selected
|
||||
],
|
||||
],
|
||||
'bExtensionCanBeChoosen' => true,
|
||||
'aMissingDependencies' => [],
|
||||
'bIsVisible' => true,
|
||||
'bExpectedAdditionalExtensions' => [
|
||||
],
|
||||
'bExpectedAdditionalModules' => [
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ProcessExtensionModulesNotSpecifiedInChoicesProvider
|
||||
*/
|
||||
public function testProcessExtensionModulesNotSpecifiedInChoices(array $aExtensionData, bool $bExtensionCanBeChoosen,
|
||||
array $aMissingDependencies, bool $bIsVisible, array $bExpectedAdditionalExtensions, array $bExpectedAdditionalModules) {
|
||||
$sPath = $this->GetInstallationPath();
|
||||
$oInstallationFileService = new InstallationFileService($sPath, 'production', [], true);
|
||||
|
||||
$oProductionEnv = $this->createMock(RunTimeEnvironment::class);
|
||||
$oProductionEnv->expects($this->once())
|
||||
->method('AnalyzeInstallation')
|
||||
->willReturn($this->GetMockListOfFoundModules());
|
||||
$oInstallationFileService->SetProductionEnv($oProductionEnv);
|
||||
|
||||
$oItopExtensionsMap = $this->createMock(ItopExtensionsMap::class);
|
||||
$aItopExtensionMap = [];
|
||||
|
||||
$sSource = $bExtensionCanBeChoosen ? iTopExtension::SOURCE_REMOTE : iTopExtension::SOURCE_WIZARD;
|
||||
foreach ($aExtensionData as $sExtensionCode => $aModules){
|
||||
$aItopExtensionMap[]= $this->CreateItopExtension($sSource, $sExtensionCode, $aModules, $aMissingDependencies, $bIsVisible);
|
||||
}
|
||||
$oItopExtensionsMap->expects($this->once())
|
||||
->method('GetAllExtensions')
|
||||
->willReturn($aItopExtensionMap);
|
||||
$oInstallationFileService->SetItopExtensionsMap($oItopExtensionsMap);
|
||||
|
||||
$sPath = realpath($this->GetInstallationPath());
|
||||
$oInstallationFileService = new \InstallationFileService($sPath, 'production', [], false);
|
||||
$oInstallationFileService->Init();
|
||||
|
||||
$aSelectedModules = $oInstallationFileService->GetSelectedModules();
|
||||
$this->assertEquals($bModuleInProductionModulesFolder, array_key_exists($sModuleId, $aSelectedModules));
|
||||
$aSelectedModules = array_keys($oInstallationFileService->GetSelectedModules());
|
||||
sort($aSelectedModules);
|
||||
$aExpectedInstallationModules = array_merge($bExpectedAdditionalModules, [
|
||||
"itop-config-mgmt",
|
||||
"itop-attachments",
|
||||
"itop-profiles-itil",
|
||||
"itop-welcome-itil",
|
||||
"itop-tickets",
|
||||
"itop-files-information",
|
||||
"combodo-db-tools",
|
||||
"itop-core-update",
|
||||
"itop-hub-connector",
|
||||
"itop-oauth-client",
|
||||
"itop-datacenter-mgmt",
|
||||
"itop-endusers-devices",
|
||||
"itop-storage-mgmt",
|
||||
"itop-virtualization-mgmt",
|
||||
"itop-service-mgmt",
|
||||
"itop-request-mgmt",
|
||||
"itop-portal",
|
||||
"itop-portal-base",
|
||||
"itop-change-mgmt",
|
||||
"itop-problem-mgmt",
|
||||
"itop-knownerror-mgmt",
|
||||
'authent-cas',
|
||||
'authent-external',
|
||||
'authent-ldap',
|
||||
'authent-local',
|
||||
'itop-backup',
|
||||
'itop-config',
|
||||
'itop-sla-computation',
|
||||
'itop-bridge-virtualization-storage',
|
||||
]);
|
||||
sort($aExpectedInstallationModules);
|
||||
|
||||
$this->assertEquals($aExpectedInstallationModules, $aSelectedModules);
|
||||
|
||||
$this->ValidateNonItilExtensionComputation($oInstallationFileService, true, $bExpectedAdditionalExtensions);
|
||||
}
|
||||
|
||||
private function RecurseMoveDir($sFromDir, $sToDir) {
|
||||
if (! is_dir($sFromDir)){
|
||||
return;
|
||||
}
|
||||
|
||||
if (! is_dir($sToDir)){
|
||||
@mkdir($sToDir);
|
||||
}
|
||||
|
||||
foreach (glob("$sFromDir/*") as $sPath){
|
||||
$sToPath = $sToDir.'/'.basename($sPath);
|
||||
if (is_file($sPath)){
|
||||
@rename($sPath, $sToPath);
|
||||
} else {
|
||||
$this->RecurseMoveDir($sPath, $sToPath);
|
||||
}
|
||||
}
|
||||
|
||||
@rmdir($sFromDir);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user