mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Removing config file writing in OQL PHPUnit tests (#238)
This commit is contained in:
@@ -69,15 +69,6 @@ class OQLToSQLAllCLassesTest 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');
|
||||
}
|
||||
|
||||
@@ -100,15 +91,19 @@ class OQLToSQLAllCLassesTest extends ItopDataTestCase
|
||||
*/
|
||||
public function testOQLLegacyAllClasses($sOQL, $aOrderBy = array(), $aArgs = array(), $aAttToLoad = null, $aExtendedDataSpec = null, $iLimitCount = 20, $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))
|
||||
{
|
||||
$aResult = $this->OQLSelectRunner($sOQL, $aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart);
|
||||
if (is_null($aPrevious)) {
|
||||
$aResult = $this->OQLSelectRunner($sOQL, $aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart);
|
||||
// no test yet, just save
|
||||
$this->SaveTestResult($this->GetId(), $aResult);
|
||||
$this->debug("Test result saved");
|
||||
@@ -116,27 +111,8 @@ class OQLToSQLAllCLassesTest extends ItopDataTestCase
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
*
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
*/
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider OQLSelectProvider
|
||||
* @depends testOQLSetup
|
||||
*
|
||||
* @param $sOQL
|
||||
*
|
||||
@@ -153,6 +129,11 @@ class OQLToSQLAllCLassesTest extends ItopDataTestCase
|
||||
*/
|
||||
public function testOQLAllClasses($sOQL, $aOrderBy = array(), $aArgs = array(), $aAttToLoad = null, $aExtendedDataSpec = null, $iLimitCount = 20, $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'));
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -31,29 +31,9 @@ class OQLToSQLNestedSelectTest extends ItopDataTestCase
|
||||
SetupUtils::builddir(APPROOT.'log/test/OQLToSQL');
|
||||
}
|
||||
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
*
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
*/
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @group itopConfigMgmt
|
||||
* @dataProvider OQLSelectProvider
|
||||
* @depends testOQLSetup
|
||||
*
|
||||
* @param $sOQL
|
||||
*
|
||||
@@ -70,6 +50,11 @@ class OQLToSQLNestedSelectTest extends ItopDataTestCase
|
||||
*/
|
||||
public function testOQLSelect($sOQL, $aOrderBy = array(), $aArgs = array(), $aAttToLoad = null, $aExtendedDataSpec = null, $iLimitCount = 20, $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'));
|
||||
|
||||
@@ -63,15 +63,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');
|
||||
}
|
||||
|
||||
@@ -94,14 +85,18 @@ class OQLToSQLTest extends ItopDataTestCase
|
||||
*/
|
||||
public function testOQLLegacySelect($sOQL, $aOrderBy = array(), $aArgs = array(), $aAttToLoad = null, $aExtendedDataSpec = null, $iLimitCount = 20, $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->OQLSelectRunner($sOQL, $aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart);
|
||||
// no test yet, just save
|
||||
$this->SaveTestResult($this->GetId(), $aResult);
|
||||
@@ -118,15 +113,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',
|
||||
@@ -157,6 +143,11 @@ class OQLToSQLTest extends ItopDataTestCase
|
||||
*/
|
||||
public function testOQLSelect($sOQL, $aOrderBy = array(), $aArgs = array(), $aAttToLoad = null, $aExtendedDataSpec = null, $iLimitCount = 20, $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'));
|
||||
|
||||
Reference in New Issue
Block a user