mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°8632 - Various fixes (#814)
* N°8632 - Check existence of parameter file within iTop * N°8632 - block parameter file from request * log on error * PHP CS fixer * N°8632 - param files must be outside iTop * PHP CS fixer * Update webservices/export.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update tests/php-unit-tests/unitary-tests/application/utilsTest.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * ✅ Fix CI --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -996,4 +996,46 @@ HTML,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function testLoadParamFile()
|
||||
{
|
||||
$sTmpFileInsideItop = APPROOT.'data/test/testLoadParamFile.params';
|
||||
$sDir = dirname($sTmpFileInsideItop);
|
||||
if (!is_dir($sDir)) {
|
||||
mkdir($sDir, 0777, true);
|
||||
}
|
||||
$sParamName = 'IP1';
|
||||
$sParamValue = 'IV1';
|
||||
$sParams = <<<INI
|
||||
# comment
|
||||
$sParamName = $sParamValue
|
||||
INI;
|
||||
file_put_contents($sTmpFileInsideItop, $sParams);
|
||||
|
||||
try {
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessage("File '$sTmpFileInsideItop' should be outside iTop");
|
||||
self::InvokeNonPublicStaticMethod(utils::class, 'LoadParamFile', [$sTmpFileInsideItop]);
|
||||
self::assertNotEquals($sParamValue, utils::ReadParam($sParamName, null), "utils::LoadParamFile() should NOT have loaded the file: $sTmpFileInsideItop");
|
||||
} finally {
|
||||
if (file_exists($sTmpFileInsideItop)) {
|
||||
unlink($sTmpFileInsideItop);
|
||||
}
|
||||
}
|
||||
|
||||
$sParamName = 'OP2';
|
||||
$sParamValue = 'OV2';
|
||||
|
||||
$sTmpFileOutsideItop = tempnam(sys_get_temp_dir(), 'utils-test');
|
||||
$sParams = <<<INI
|
||||
# comment
|
||||
$sParamName = $sParamValue
|
||||
INI;
|
||||
|
||||
file_put_contents($sTmpFileOutsideItop, $sParams);
|
||||
self::InvokeNonPublicStaticMethod(utils::class, 'LoadParamFile', [$sTmpFileOutsideItop]);
|
||||
self::assertEquals($sParamValue, utils::ReadParam($sParamName, null), "utils::LoadParamFile() should have loaded the file: $sTmpFileOutsideItop");
|
||||
|
||||
unlink($sTmpFileOutsideItop);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user