Advanced Search: code hardening and unit tests

SVN:b1162[5544]
This commit is contained in:
Eric Espié
2018-03-27 10:14:27 +00:00
parent 7672858d6b
commit bc9e1b1d94
4 changed files with 88 additions and 64 deletions

View File

@@ -318,13 +318,13 @@ class CriterionConversionTest extends ItopDataTestCase
if ($aCriteria['widget'] != \AttributeDefinition::SEARCH_WIDGET_TYPE_RAW)
{
unset($aCriteria['oql']);
if (isset($aFields['zlist'][$aCriteria['ref']]))
foreach($aFields as $aCatFields)
{
$aField = $aFields['zlist'][$aCriteria['ref']];
}
elseif (isset($aFields['others'][$aCriteria['ref']]))
{
$aField = $aFields['others'][$aCriteria['ref']];
if (isset($aCatFields[$aCriteria['ref']]))
{
$aField = $aCatFields[$aCriteria['ref']];
break;
}
}
if (isset($aField))
{

View File

@@ -48,6 +48,7 @@ class SearchFormTest extends ItopDataTestCase
$oSearchForm = new SearchForm();
$oSearch = \DBSearch::FromOQL($sOQL);
$aFields = $oSearchForm->GetFields(new \DBObjectSet($oSearch));
$this->debug($sOQL);
$this->debug(json_encode($aFields, JSON_PRETTY_PRINT));
$this->assertCount($iNum, $aFields[$sList]);
@@ -59,6 +60,11 @@ class SearchFormTest extends ItopDataTestCase
array("SELECT Contact", 8, 'zlist'),
array("SELECT Contact AS C WHERE C.status = 'active'", 4, 'others'),
array("SELECT Person", 12, 'zlist'),
array(
"SELECT Person AS p JOIN UserRequest AS u ON u.agent_id = p.id WHERE u.status != 'closed'",
12,
'zlist'
),
);
}