mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 10:08:45 +02:00
Merge remote-tracking branch 'origin/support/3.0' into support/3.1
# Conflicts: # tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php
This commit is contained in:
@@ -8,11 +8,6 @@ use DBRestore;
|
||||
use MetaModel;
|
||||
use SetupUtils;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class DBBackupDataTest extends ItopDataTestCase
|
||||
{
|
||||
/**
|
||||
@@ -32,35 +27,33 @@ class DBBackupDataTest extends ItopDataTestCase
|
||||
file_put_contents(APPROOT.'/'.$sExtraFile, 'Hello World!');
|
||||
}
|
||||
}
|
||||
|
||||
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]);
|
||||
SetupUtils::rrmdir($sTmpDir);
|
||||
$aExpectedFiles = [
|
||||
$sTmpDir.'/config-itop.php',
|
||||
];
|
||||
foreach($aExtraFiles as $sRelFile => $bExists)
|
||||
{
|
||||
if ($bExists)
|
||||
{
|
||||
$aExpectedFiles[] = $sTmpDir.'/'.$sRelFile;
|
||||
|
||||
try {
|
||||
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]);
|
||||
SetupUtils::rrmdir($sTmpDir);
|
||||
$aExpectedFiles = [
|
||||
$sTmpDir . '/config-itop.php',
|
||||
];
|
||||
foreach ($aExtraFiles as $sRelFile => $bExists) {
|
||||
if ($bExists) {
|
||||
$aExpectedFiles[] = $sTmpDir . '/' . $sRelFile;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
// Cleanup
|
||||
foreach ($aExtraFiles as $sExtraFile => $bExists) {
|
||||
if ($bExists) {
|
||||
unlink(APPROOT . '/' . $sExtraFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sort($aFiles);
|
||||
sort($aExpectedFiles);
|
||||
$this->assertEquals($aFiles, $aExpectedFiles);
|
||||
|
||||
// Cleanup
|
||||
foreach($aExtraFiles as $sExtraFile => $bExists)
|
||||
{
|
||||
if ($bExists)
|
||||
{
|
||||
unlink(APPROOT.'/'.$sExtraFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function prepareFilesToBackupProvider()
|
||||
@@ -95,9 +88,15 @@ class DBBackupDataTest extends ItopDataTestCase
|
||||
$aExpectedExtraFiles = [];
|
||||
foreach($aExpectedRelativeExtraFiles as $sRelativeName)
|
||||
{
|
||||
$aExpectedExtraFiles[$sTmpDir.'/'.$sRelativeName] = APPROOT.'/'.$sRelativeName;
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
$sRelativeName = str_replace('/', '\\', $sRelativeName);
|
||||
$aExpectedExtraFiles[$sTmpDir.'\\'.$sRelativeName] = APPROOT.'\\'.$sRelativeName;
|
||||
}
|
||||
else {
|
||||
$aExpectedExtraFiles[$sTmpDir.'/'.$sRelativeName] = APPROOT.'/'.$sRelativeName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$oRestore = new DBRestore(MetaModel::GetConfig());
|
||||
$aExtraFiles = $this->InvokeNonPublicMethod('DBRestore', 'ListExtraFiles', $oRestore, [$sTmpDir]);
|
||||
|
||||
|
||||
@@ -8,11 +8,6 @@ use DateTime;
|
||||
use DBBackup;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class DBBackupTest extends ItopTestCase
|
||||
{
|
||||
protected const DUMMY_DB_HOST = 'localhost';
|
||||
@@ -32,7 +27,7 @@ class DBBackupTest extends ItopTestCase
|
||||
// We need a connection to the DB, so let's open it !
|
||||
// We are using the default config file... as the server might not be configured for all the combination we are testing
|
||||
// For example dev env and ci env won't accept TLS connection
|
||||
$oConfigOnDisk = utils::GetConfig();
|
||||
$oConfigOnDisk = utils::GetConfig(true);
|
||||
CMDBSource::InitFromConfig($oConfigOnDisk);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,7 @@ use SubMFCompiler;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
* @runClassInSeparateProcess
|
||||
* @covers \MFCompiler::UseLatestPrecompiledFile
|
||||
*/
|
||||
class MFCompilerTest extends ItopTestCase {
|
||||
@@ -53,9 +51,9 @@ class MFCompilerTest extends ItopTestCase {
|
||||
$sSourceDir = $sAppRootForProvider . 'datamodels' . DIRECTORY_SEPARATOR . '2.x';
|
||||
$sDatamodel2xTargetDir = $sSourceDir . DIRECTORY_SEPARATOR . '/UseLatestPrecompiledFileProvider';
|
||||
|
||||
mkdir($sTempTargetDir);
|
||||
mkdir($sExtensionTargetDir);
|
||||
mkdir($sDatamodel2xTargetDir);
|
||||
if (!is_dir($sTempTargetDir)) mkdir($sTempTargetDir);
|
||||
if (!is_dir($sExtensionTargetDir)) @mkdir($sExtensionTargetDir);
|
||||
if (!is_dir($sDatamodel2xTargetDir)) @mkdir($sDatamodel2xTargetDir);
|
||||
|
||||
self::$aFoldersToCleanup = [ $sTempTargetDir, $sExtensionTargetDir, $sDatamodel2xTargetDir ];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user