fix test that breaks config-itop.php

This commit is contained in:
odain
2020-07-15 19:56:25 +02:00
parent 9e3b1bfc78
commit 68c7b9a0e8

View File

@@ -9,13 +9,35 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase;
class iTopConfigParserTest extends ItopTestCase
{
private $conf_exists;
private $tmpSavePath;
private $sConfigPath;
public function setUp()
{
parent::setUp();
require_once APPROOT.'/core/iTopConfigParser.php';
clearstatcache();
$this->sConfigPath = utils::GetConfigFilePath();
$this->tmpSavePath = tempnam( '/tmp/', 'config-itop');
$this->conf_exists = is_file($this->sConfigPath);
if ($this->conf_exists)
{
copy($this->sConfigPath, $this->tmpSavePath);
}
clearstatcache();
}
public function tearDown()
{
parent::tearDown(); // TODO: Change the autogenerated stub
if ($this->conf_exists)
{
rename($this->tmpSavePath, $this->sConfigPath);
}
}
/**
* @dataProvider ParserProvider
@@ -184,33 +206,14 @@ CONF;
*/
public function testConfigWriteToFile_FromScratchInstallation()
{
clearstatcache();
$sConfigPath = utils::GetConfigFilePath();
$tmpSavePath = tempnam( '/tmp/', 'config-itop');
$conf_exists = is_file($sConfigPath);
if ($conf_exists)
{
rename($sConfigPath, $tmpSavePath);
}
$oConfig = new Config($sConfigPath, false);
try{
clearstatcache();
$oConfig->WriteToFile();
if ($conf_exists)
{
rename($tmpSavePath, $sConfigPath);
}
}catch(\Exception $e)
{
if ($conf_exists)
{
rename($tmpSavePath, $sConfigPath);
}
$this->assertTrue(false, "failed writetofile with no initial file: " . $e->getMessage());
}
}
}