Improved test and test cleanup

This commit is contained in:
jf-cbd
2024-02-21 16:30:00 +01:00
parent f41f2a063d
commit aa81c94dad

View File

@@ -32,11 +32,14 @@ class DBBackupDataTest extends ItopDataTestCase
if ($bUnsafeFileException) {
$this->expectExceptionMessage("Backup: Aborting, resource '$sExtraFile'. Considered as UNSAFE because not inside the iTop directory.");
}
$aFiles = $this->InvokeNonPublicMethod('DBBackup', 'PrepareFilesToBackup', $oBackup, [APPROOT . '/conf/production/config-itop.php', $sTmpDir, true]);
$aFiles = $this->InvokeNonPublicMethod('DBBackup', 'PrepareFilesToBackup', $oBackup, [APPROOT . '/conf/'.$this->GetTestEnvironment().'/config-itop.php', $sTmpDir, true]);
SetupUtils::rrmdir($sTmpDir);
$aExpectedFiles = [
$sTmpDir . '/config-itop.php',
];
if (file_exists(APPROOT.'/data/'.$this->GetTestEnvironment().'.delta.xml')) {
$aExpectedFiles[] = $sTmpDir . '/' . 'delta.xml';
}
foreach ($aExtraFiles as $sRelFile => $bExists) {
if ($bExists) {
$aExpectedFiles[] = $sTmpDir . '/' . $sRelFile;
@@ -47,13 +50,17 @@ class DBBackupDataTest extends ItopDataTestCase
foreach ($aExtraFiles as $sExtraFile => $bExists) {
if ($bExists) {
unlink(APPROOT . '/' . $sExtraFile);
$folderPath = dirname(APPROOT . '/' . $sExtraFile);
if (is_dir($folderPath) && count(glob($folderPath . '/*')) === 0) {
rmdir($folderPath);
}
}
}
}
sort($aFiles);
sort($aExpectedFiles);
$this->assertEquals($aFiles, $aExpectedFiles);
$this->assertEquals($aExpectedFiles, $aFiles);
}
function prepareFilesToBackupProvider()