N°9618 - Be able to write comment in MyModuleSettings

N°9618 - Be able to write comment in MyModuleSettings
This commit is contained in:
odain
2026-05-19 23:56:21 +02:00
parent b29a3b5df8
commit 2ecd2d7a96
5 changed files with 152 additions and 4 deletions

View File

@@ -72,7 +72,6 @@ class ConfigTest extends ItopTestCase
'sExpectedContains' => "'app_root_url' => 'http://%server(SERVER_NAME)?:localhost%/itop/iTop/'",
'aChanges' => [],
],
'preserve set same value' => [
'sConfigFile' => __DIR__.'/ConfigTest/config-itop-var.php',
'sExpectedContains' => "'app_root_url' => 'http://' . (isset(\$_SERVER['SERVER_NAME']) ? \$_SERVER['SERVER_NAME'] : 'localhost') . '/itop/iTop/'",
@@ -91,4 +90,21 @@ class ConfigTest extends ItopTestCase
],
];
}
public function testPreserveModuleSettingsOnWriteToFile()
{
$sTmpFile = tempnam(sys_get_temp_dir(), "target");
$sConfigFile = __DIR__.'/ConfigTest/config-itop-modulesetting.php';
$oConfig = new Config($sConfigFile);
$oConfig->WriteToFile($sTmpFile);
$this->assertFileExists($sTmpFile);
$this->assertEquals($this->GetModuleSettingSection($sConfigFile), $this->GetModuleSettingSection($sTmpFile));
}
private function GetModuleSettingSection(string $sFilePath) : string {
preg_match('/\$MyModuleSettings[\w\W]*\/\*\*/m', file_get_contents($sFilePath), $aMatches);
return preg_replace(['/[ ]+/', '/[ ]+/'],[' ', ' '], $aMatches[0]);
}
}

View File

@@ -0,0 +1,54 @@
<?php
/**
*
* Configuration file, generated for the unit tests
*
*
*
*/
$MySettings = [
];
/**
*
* Modules specific settings
*
*/
$MyModuleSettings = array(
'combodo-hybridauth' => array (
//debug to add traces...
'debug' => false,
'providers' => array (
'Keycloak' =>
/*
ga
bu
zo meu
*/
array (
'keys' =>
array (
/**
* sha
*
* dok
*/
'id' => 'my-clientid',
'secret' => 'my-secret',
),
'enabled' => false,
),
//url to access IdP
'url' => 'keycloak_url',
),
),
);
/**
*
* Data model modules to be loaded. Names are specified as relative paths
*
*/
$MyModules = [
];