mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
fix test that breaks config-itop.php
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user