From aa81c94dad048606eba79ecebbc45533672f0fe0 Mon Sep 17 00:00:00 2001 From: jf-cbd Date: Wed, 21 Feb 2024 16:30:00 +0100 Subject: [PATCH] Improved test and test cleanup --- .../unitary-tests/setup/DBBackupDataTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/php-unit-tests/unitary-tests/setup/DBBackupDataTest.php b/tests/php-unit-tests/unitary-tests/setup/DBBackupDataTest.php index 129664c74..1952c2c84 100644 --- a/tests/php-unit-tests/unitary-tests/setup/DBBackupDataTest.php +++ b/tests/php-unit-tests/unitary-tests/setup/DBBackupDataTest.php @@ -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()