diff --git a/tests/php-unit-tests/unitary-tests/core/OQLTest.php b/tests/php-unit-tests/unitary-tests/core/OQLTest.php index d6d7674ae..40a2e0845 100644 --- a/tests/php-unit-tests/unitary-tests/core/OQLTest.php +++ b/tests/php-unit-tests/unitary-tests/core/OQLTest.php @@ -38,13 +38,15 @@ class OQLTest extends ItopDataTestCase */ public function testOQLSetup() { - utils::GetConfig()->Set('apc_cache.enabled', false, 'test'); - utils::GetConfig()->Set('query_cache_enabled', false, 'test'); - utils::GetConfig()->Set('expression_cache_enabled', false, 'test'); - $sConfigFile = utils::GetConfig()->GetLoadedFile(); + $oConfig = utils::GetConfig(); + $oConfig->Set('apc_cache.enabled', false, 'test'); + $oConfig->Set('query_cache_enabled', false, 'test'); + $oConfig->Set('expression_cache_enabled', false, 'test'); + + $sConfigFile = $oConfig->GetLoadedFile(); @chmod($sConfigFile, 0770); - utils::GetConfig()->WriteToFile(); - @chmod($sConfigFile, 0444); // Read-only + $oConfig->WriteToFile(); + @chmod($sConfigFile, 0444); } /** diff --git a/tests/php-unit-tests/unitary-tests/core/iTopConfigParserTest.php b/tests/php-unit-tests/unitary-tests/core/iTopConfigParserTest.php index fd47d9a74..e096c9981 100644 --- a/tests/php-unit-tests/unitary-tests/core/iTopConfigParserTest.php +++ b/tests/php-unit-tests/unitary-tests/core/iTopConfigParserTest.php @@ -44,10 +44,10 @@ class iTopConfigParserTest extends ItopTestCase parent::tearDown(); if ($this->conf_exists) { // restoring config that was in place before the test - $sBackupConfigFileContent = file_get_contents($this->tmpSavePath); - $hItopConfigFile = @fopen($this->sConfigPath, 'w'); - fwrite($hItopConfigFile, $sBackupConfigFileContent); - fclose($hItopConfigFile); + @chmod($this->sConfigPath, 0770); + $bRenameResult = rename($this->tmpSavePath, $this->sConfigPath); + echo "Restored config file, result={$bRenameResult}"; + @chmod($this->sConfigPath, 0440); } } diff --git a/tests/php-unit-tests/unitary-tests/webservices/RestTest.php b/tests/php-unit-tests/unitary-tests/webservices/RestTest.php index a4caf209b..3b0537e9f 100644 --- a/tests/php-unit-tests/unitary-tests/webservices/RestTest.php +++ b/tests/php-unit-tests/unitary-tests/webservices/RestTest.php @@ -42,20 +42,16 @@ class RestTest extends ItopDataTestCase unlink($this->sTmpFile); } - $sConfigFile = \utils::GetConfig()->GetLoadedFile(); - @chmod($sConfigFile, 0770); - $this->sUrl = \MetaModel::GetConfig()->Get('app_root_url'); - @chmod($sConfigFile, 0444); // Read-only + $this->sUrl = \MetaModel::GetConfig()->Get('app_root_url'); - $oRestProfile = \MetaModel::GetObjectFromOQL("SELECT URP_Profiles WHERE name = :name", array('name' => 'REST Services User'), true); - $oAdminProfile = \MetaModel::GetObjectFromOQL("SELECT URP_Profiles WHERE name = :name", array('name' => 'Administrator'), true); + $oRestProfile = \MetaModel::GetObjectFromOQL("SELECT URP_Profiles WHERE name = :name", array('name' => 'REST Services User'), true); + $oAdminProfile = \MetaModel::GetObjectFromOQL("SELECT URP_Profiles WHERE name = :name", array('name' => 'Administrator'), true); - if (is_object($oRestProfile) && is_object($oAdminProfile)) - { - $oUser = $this->CreateUser($this->sLogin, $oRestProfile->GetKey(), $this->sPassword); - $this->AddProfileToUser($oUser, $oAdminProfile->GetKey()); - } - } + if (is_object($oRestProfile) && is_object($oAdminProfile)) { + $oUser = $this->CreateUser($this->sLogin, $oRestProfile->GetKey(), $this->sPassword); + $this->AddProfileToUser($oUser, $oAdminProfile->GetKey()); + } + } /** * @dataProvider BasicProvider @@ -70,7 +66,7 @@ class RestTest extends ItopDataTestCase $sOutputJson = $this->CreateTicketViaApi($description); $this->debug("Output: '$sOutputJson'"); $aJson = json_decode($sOutputJson, true); - $this->assertNotNull($aJson, 'json_decode() on the REST API response returned null :('); + $this->assertNotNull($aJson, "Cannot decode returned JSON : $sOutputJson"); if ($this->iJsonDataMode === self::MODE['NO_JSONDATA']){ $this->assertStringContainsString("3", "".$aJson['code'], $sOutputJson);