diff --git a/test/core/iTopConfigParserTest.php b/test/core/iTopConfigParserTest.php index 0461f6391..ee393a1b2 100644 --- a/test/core/iTopConfigParserTest.php +++ b/test/core/iTopConfigParserTest.php @@ -10,6 +10,7 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase; class iTopConfigParserTest extends ItopTestCase { private $conf_exists; + /** @var false|string backup of the original config file */ private $tmpSavePath; private $sConfigPath; @@ -20,7 +21,8 @@ class iTopConfigParserTest extends ItopTestCase clearstatcache(); $this->sConfigPath = utils::GetConfigFilePath(); - $this->tmpSavePath = tempnam( '/tmp/', 'config-itop'); + // saving the current config so we can restore it at the end ! + $this->tmpSavePath = tempnam(sys_get_temp_dir(), 'config-itop'); $this->conf_exists = is_file($this->sConfigPath); if ($this->conf_exists) @@ -32,9 +34,10 @@ class iTopConfigParserTest extends ItopTestCase public function tearDown() { - parent::tearDown(); // TODO: Change the autogenerated stub - if ($this->conf_exists) - { + parent::tearDown(); + if ($this->conf_exists) { + // restoring config that was in place before the test + @chmod($this->sConfigPath, 0770); // RWX for owner and group, nothing for others : else we will have permission denied ! rename($this->tmpSavePath, $this->sConfigPath); } } @@ -154,8 +157,8 @@ class iTopConfigParserTest extends ItopTestCase */ public function testConfigWriteToFile() { - $tmpConfigFileBeforePath = tempnam( '/tmp/', 'config-itop'); - $tmpConfigFileAfterPath = tempnam( '/tmp/', 'config-itop'); + $tmpConfigFileBeforePath = tempnam(sys_get_temp_dir(), 'config-itop'); + $tmpConfigFileAfterPath = tempnam(sys_get_temp_dir(), 'config-itop'); //create new config file $sConfigFile = utils::GetConfig()->GetLoadedFile();