Compare commits

...

2 Commits

Author SHA1 Message Date
Eric Espié
7c8cf670c5 Delete .idea directory
problems with phpstorm
2026-11-25 14:51:29 +01:00
Benjamin DALSASS
c1d0fe3640 N°9728 - improve config editor
- update unitary test for removed addons
2026-11-25 10:52:49 +01:00
2 changed files with 5 additions and 55 deletions

15
.idea/IntelliLang.xml generated
View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="LanguageInjectionConfiguration">
<injection language="InjectablePHP" injector-id="xml">
<display-name>iTop - Class method code</display-name>
<place><![CDATA[xmlTag().withLocalName(string().equalTo("code"))]]></place>
<xpath-condition>name(..) = 'method' and count(/itop_design) = 1</xpath-condition>
</injection>
<injection language="InjectablePHP" injector-id="xml">
<display-name>iTop - Snippet code</display-name>
<place><![CDATA[xmlTag().withLocalName(string().equalTo("snippet"))]]></place>
<xpath-condition>name(..) = 'snippets' and count(/itop_design) = 1</xpath-condition>
</injection>
</component>
</project>

View File

@@ -109,7 +109,7 @@ class ConfigTest extends ItopTestCase
$this->AssertWriteToFilePreservesSettings($oConfig, [
'existing-module' => ['existing.property' => true],
$key => ['sample.property' => 'value'],
], $oConfig->GetAddons());
]);
}
/**
@@ -127,40 +127,7 @@ class ConfigTest extends ItopTestCase
'existing.property' => true,
$key => [$key => 'value'],
],
], $oConfig->GetAddons());
}
/**
* @since 3.2.3
* @dataProvider ProviderArrayKeys
*/
public function testWriteToFilePreservesAddons(int|string $key): void
{
$oConfig = new Config();
$aAddons = $oConfig->GetAddons();
$aAddons[$key] = 'addons/'.$key.'/module.php';
$oConfig->SetAddons($aAddons);
$this->AssertWriteToFilePreservesSettings($oConfig, [], $aAddons);
}
/**
* @since 3.2.3
* @dataProvider ProviderArrayKeys
*/
public function testWriteToFilePreservesIncrementalAddons(int|string $key): void
{
$aAddons = (new Config())->GetAddons();
$aAddons[$key] = 'addons/'.$key.'/module.php';
$sSourceFile = tempnam(sys_get_temp_dir(), 'config-source');
$this->aFileToClean[] = $sSourceFile;
$this->assertNotFalse(file_put_contents($sSourceFile, "<?php\n"
."\$MySettings = [];\n"
."\$MyModuleSettings = [];\n"
."\$MyModules = [];\n"
."\$MyModules['addons'] = ".var_export($aAddons, true).";\n"));
$this->AssertWriteToFilePreservesSettings(new Config($sSourceFile), [], $aAddons);
]);
}
/**
@@ -192,12 +159,11 @@ class ConfigTest extends ItopTestCase
/**
* @since 3.2.3
* @param array<int|string, array<int|string, mixed>> $aModuleSettings
* @param array<int|string, string> $aAddons
*/
private function AssertWriteToFilePreservesSettings(Config $oConfig, array $aModuleSettings, array $aAddons): void
private function AssertWriteToFilePreservesSettings(Config $oConfig, array $aModuleSettings): void
{
$oOriginalConfig = utils::GetConfig();
$oParser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
$oParser = (new ParserFactory())->createForNewestSupportedVersion();
$oEvaluator = new ConstExprEvaluator();
try {
@@ -217,10 +183,9 @@ class ConfigTest extends ItopTestCase
}
$this->assertSame(['MySettings', 'MyModuleSettings', 'MyModules'], array_keys($aValues));
$this->assertSame($aModuleSettings, $aValues['MyModuleSettings']);
$this->assertSame(['addons' => $aAddons], $aValues['MyModules']);
$this->assertSame([], $aValues['MyModules']);
$oConfig = new Config($sTargetFile);
$this->assertSame($aAddons, $oConfig->GetAddons());
foreach ($aModuleSettings as $sModule => $aProperties) {
foreach ($aProperties as $sProperty => $value) {
$this->assertSame($value, $oConfig->GetModuleSetting($sModule, $sProperty));