mirror of
https://github.com/Combodo/iTop.git
synced 2026-11-25 16:18:57 +01:00
Compare commits
2 Commits
feature/97
...
support/3.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c8cf670c5 | ||
|
|
c1d0fe3640 |
15
.idea/IntelliLang.xml
generated
15
.idea/IntelliLang.xml
generated
@@ -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>
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user