💚 Refactor unit tests

This commit is contained in:
Eric
2019-10-23 16:41:28 +02:00
parent 5642552f9a
commit b7c3fbb176
14 changed files with 24 additions and 16 deletions

View File

@@ -65,7 +65,7 @@ class ItopDataTestCase extends ItopTestCase
private $aCreatedObjects = array();
const USE_TRANSACTION = true;
const CREATE_TEST_ORG = true;
const CREATE_TEST_ORG = false;
/**
* @throws Exception

View File

@@ -37,7 +37,9 @@ use Combodo\iTop\Application\Search\CriterionParser;
use Combodo\iTop\Application\Search\SearchForm;
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
use DBObjectSearch;
use DBObjectSet;
use DBSearch;
use Dict;
/**
* @runTestsInSeparateProcesses
@@ -46,6 +48,8 @@ use DBSearch;
*/
class CriterionConversionTest extends ItopDataTestCase
{
const CREATE_TEST_ORG = true;
/**
* @throws \Exception
*/
@@ -186,7 +190,7 @@ class CriterionConversionTest extends ItopDataTestCase
$oSearchForm = new SearchForm();
/** @var \DBObjectSearch $oSearch */
$oSearch = DBSearch::FromOQL("SELECT Contact");
$aFields = $oSearchForm->GetFields(new \DBObjectSet($oSearch));
$aFields = $oSearchForm->GetFields(new DBObjectSet($oSearch));
$aRes = CriterionToSearchForm::Convert($aCriterion, $aFields, $oSearch->GetJoinedClasses());
$this->debug($aRes);
$this->assertEquals($sExpectedOperator, $aRes[0]['operator']);
@@ -634,12 +638,12 @@ class CriterionConversionTest extends ItopDataTestCase
$this->debug($sOQL);
\Dict::SetUserLanguage($sLanguageCode);
Dict::SetUserLanguage($sLanguageCode);
$oSearchForm = new SearchForm();
$oSearch = \DBSearch::FromOQL($sOQL);
$aFields = $oSearchForm->GetFields(new \DBObjectSet($oSearch));
$oSearch = DBSearch::FromOQL($sOQL);
$aFields = $oSearchForm->GetFields(new DBObjectSet($oSearch));
/** @var \DBObjectSearch $oSearch */
$aCriterion = $oSearchForm->GetCriterion($oSearch, $aFields);
@@ -648,7 +652,7 @@ class CriterionConversionTest extends ItopDataTestCase
$aNewCriterion = array();
foreach($aAndCriterion as $aCriteria)
{
if ($aCriteria['widget'] != \AttributeDefinition::SEARCH_WIDGET_TYPE_RAW)
if ($aCriteria['widget'] != AttributeDefinition::SEARCH_WIDGET_TYPE_RAW)
{
unset($aCriteria['oql']);
foreach($aFields as $aCatFields)

View File

@@ -29,19 +29,20 @@
namespace Combodo\iTop\Test\UnitTest\Application\Search;
use Combodo\iTop\Application\Search\CriterionParser;
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
use Combodo\iTop\Test\UnitTest\ItopTestCase;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class CriterionParserTest extends ItopDataTestCase
class CriterionParserTest extends ItopTestCase
{
protected function setUp()
{
parent::setUp();
require_once(APPROOT."application/startup.inc.php");
require_once(APPROOT."sources/application/search/criterionparser.class.inc.php");
}

View File

@@ -34,6 +34,7 @@ use Exception;
*/
class SearchFormTest extends ItopDataTestCase
{
const CREATE_TEST_ORG = true;
/**
* @throws Exception

View File

@@ -37,6 +37,8 @@ use DBObject;
*/
class DBObjectTest extends ItopDataTestCase
{
const CREATE_TEST_ORG = true;
protected function setUp()
{
parent::setUp();

View File

@@ -17,8 +17,6 @@ use DBSearch;
*/
class DBSearchIntersectTest extends ItopDataTestCase
{
const CREATE_TEST_ORG = false;
protected function setUp()
{
parent::setUp();

View File

@@ -47,6 +47,7 @@ use FunctionExpression;
*/
class DBSearchTest extends ItopDataTestCase
{
const CREATE_TEST_ORG = true;
/**
* @throws \Exception

View File

@@ -83,4 +83,4 @@ class MetaModelTest extends ItopDataTestCase
),
);
}
}
}

View File

@@ -21,7 +21,6 @@ use utils;
class OQLToSQLAllCLassesTest extends ItopDataTestCase
{
const USE_TRANSACTION = false;
const CREATE_TEST_ORG = false;
public function setUp()
{

View File

@@ -15,7 +15,6 @@ use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
class OQLToSQLTest extends ItopDataTestCase
{
const USE_TRANSACTION = false;
const CREATE_TEST_ORG = false;
const TEST_CSV_RESULT = 'OQLToSQLTest.csv';
public function setUp()

View File

@@ -20,7 +20,6 @@ use utils;
class OQLToSQLTest extends ItopDataTestCase
{
const USE_TRANSACTION = false;
const CREATE_TEST_ORG = false;
const TEST_CSV_RESULT = 'OQLToSQLTest.csv';
public function setUp()

View File

@@ -42,8 +42,9 @@ use ormLinkSet;
*/
class ormLinkSetTest extends ItopDataTestCase
{
const CREATE_TEST_ORG = true;
/**
/**
* @throws Exception
*/
protected function setUp()

View File

@@ -44,6 +44,7 @@ define('MAX_TAGS', 12);
*/
class ormTagSetTest extends ItopDataTestCase
{
const CREATE_TEST_ORG = true;
/**
* @throws Exception

View File

@@ -37,7 +37,9 @@ use Exception;
*/
class ItopTicketTest extends ItopDataTestCase
{
/**
const CREATE_TEST_ORG = true;
/**
* @throws Exception
*/
protected function setUp()