Removing config file writing in OQL PHPUnit tests (#238)

This commit is contained in:
Pierre Goiffon
2021-10-18 16:37:24 +02:00
committed by GitHub
parent 020460d048
commit 6abdabd197
4 changed files with 39 additions and 91 deletions

View File

@@ -56,15 +56,6 @@ class OQLToSQLTest extends ItopDataTestCase
*/
public function testOQLLegacySetup()
{
utils::GetConfig()->Set('use_legacy_dbsearch', true, 'Test');
utils::GetConfig()->Set('apc_cache.enabled', false, 'Test');
utils::GetConfig()->Set('expression_cache_enabled', false, 'Test');
utils::GetConfig()->Set('query_cache_enabled', false, 'Test');
$sConfigFile = utils::GetConfig()->GetLoadedFile();
@chmod($sConfigFile, 0770);
utils::GetConfig()->WriteToFile();
@chmod($sConfigFile, 0444); // Read-only
SetupUtils::rrmdir($sResultFile = APPROOT.'log/test');
}
@@ -88,14 +79,18 @@ class OQLToSQLTest extends ItopDataTestCase
*/
public function testOQLGroupByLegacy($sOQL, $aArgs, $aGroupByExpr, $bExcludeNullValues = false, $aSelectExpr = array(), $aOrderBy = array(), $iLimitCount = 0, $iLimitStart = 0)
{
utils::GetConfig()->Set('use_legacy_dbsearch', true, 'Test');
utils::GetConfig()->Set('apc_cache.enabled', false, 'Test');
utils::GetConfig()->Set('expression_cache_enabled', false, 'Test');
utils::GetConfig()->Set('query_cache_enabled', false, 'Test');
$this->assertTrue(utils::GetConfig()->Get('use_legacy_dbsearch'));
$this->assertFalse(utils::GetConfig()->Get('apc_cache.enabled'));
$this->assertFalse(utils::GetConfig()->Get('query_cache_enabled'));
$this->assertFalse(utils::GetConfig()->Get('expression_cache_enabled'));
$aPrevious = $this->GetPreviousTestResult($this->GetId());
if (is_null($aPrevious))
{
if (is_null($aPrevious)) {
$aResult = $this->OQLGroupByRunner($sOQL, $aArgs, $aGroupByExpr, $bExcludeNullValues, $aSelectExpr, $aOrderBy, $iLimitCount, $iLimitStart);
// no test yet, just save
$this->SaveTestResult($this->GetId(), $aResult);
@@ -112,15 +107,6 @@ class OQLToSQLTest extends ItopDataTestCase
*/
public function testOQLSetup()
{
utils::GetConfig()->Set('use_legacy_dbsearch', false, 'test');
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();
@chmod($sConfigFile, 0770);
utils::GetConfig()->WriteToFile();
@chmod($sConfigFile, 0444); // Read-only
$aCSVHeader = array(
'test', 'OQL','count',
'Legacy Count Joins', 'Count Joins',
@@ -152,6 +138,11 @@ class OQLToSQLTest extends ItopDataTestCase
*/
public function testOQLGroupBy($sOQL, $aArgs, $aGroupByExpr, $bExcludeNullValues = false, $aSelectExpr = array(), $aOrderBy = array(), $iLimitCount = 0, $iLimitStart = 0)
{
utils::GetConfig()->Set('use_legacy_dbsearch', false, 'test');
utils::GetConfig()->Set('apc_cache.enabled', false, 'test');
utils::GetConfig()->Set('query_cache_enabled', false, 'test');
utils::GetConfig()->Set('expression_cache_enabled', false, 'test');
$this->assertFalse(utils::GetConfig()->Get('use_legacy_dbsearch'));
$this->assertFalse(utils::GetConfig()->Get('apc_cache.enabled'));
$this->assertFalse(utils::GetConfig()->Get('query_cache_enabled'));