diff --git a/test/core/iTopConfigParserTest.php b/test/core/iTopConfigParserTest.php index 0256201be..0461f6391 100644 --- a/test/core/iTopConfigParserTest.php +++ b/test/core/iTopConfigParserTest.php @@ -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()); } - } }