Merge branch release/21.7.6 of zentao/zentaopms (#11436)

This commit is contained in:
刘刚
2025-09-11 17:44:40 +08:00
committed by Gitfox
4 changed files with 48 additions and 69 deletions
@@ -65,7 +65,7 @@ class searchTest
* 测试生成查询表单数据。
* Process query form datas test.
*
* @param object $fieldParams
* @param array $fieldParams
* @param string $field
* @param string $andOrName
* @param string $operatorName
@@ -73,23 +73,11 @@ class searchTest
* @access public
* @return object
*/
public function processQueryFormDatasTest(object $postData, string $field, string $andOrName, string $operatorName, string $valueName): object
public function processQueryFormDatasTest(array $fieldParams, string $field, string $andOrName, string $operatorName, string $valueName): array
{
$_POST = (array)$postData;
$_POST = $fieldParams;
global $tester;
$tester->loadModel('bug');
$fieldParams = json_decode(json_encode($tester->config->bug->search['params']));
list($andOr, $operator, $value) = $this->objectModel->processQueryFormDatas($fieldParams, $field, $andOrName, $operatorName, $valueName);
$queryFormData = new stdclass();
$queryFormData->andOr = $andOr;
$queryFormData->operator = $operator;
$queryFormData->value = $value;
return $queryFormData;
return $this->objectModel->processQueryFormDatas($fieldParams, $field, $andOrName, $operatorName, $valueName);
}
/**
@@ -8,10 +8,15 @@ timeout=0
cid=1
- 测试设置 products 的默认参数 @1,2,3,4,5,6,7,8,9,10,null
- 测试设置 users 的默认参数 @,admin,user1,user2,user3,user4,$me,null
- 测试设置 users 的默认参数 @admin,user1,user2,user3,user4,$me,null
- 测试设置 executions 的默认参数 @,null
- 测试设置 空数组 的默认参数 @,null
- 测试设置 空字符串 的默认参数 @0,null
- 测试设置 array(1) 的默认参数 @ZERO
- 测试设置 nonull 的默认参数 @0
@@ -44,9 +49,9 @@ $params7 = array('product' => array('values' => array(''), 'nonull' => true))
$search = new searchTest();
r($search->setDefaultParamsTest($fields1, $params1)) && p('0') && e('1,2,3,4,5,6,7,8,9,10,null'); // 测试设置 products 的默认参数
r($search->setDefaultParamsTest($fields2, $params2)) && p('0') && e(',admin,user1,user2,user3,user4,$me,null'); // 测试设置 users 的默认参数
r($search->setDefaultParamsTest($fields2, $params2)) && p('0') && e('admin,user1,user2,user3,user4,$me,null'); // 测试设置 users 的默认参数
r($search->setDefaultParamsTest($fields3, $params3)) && p('0') && e(',null'); // 测试设置 executions 的默认参数
r($search->setDefaultParamsTest($fields4, $params4)) && p('0') && e(',null'); // 测试设置 空数组 的默认参数
r($search->setDefaultParamsTest($fields5, $params5)) && p('0') && e('0,null'); // 测试设置 空字符串 的默认参数
r($search->setDefaultParamsTest($fields6, $params6)) && p('0') && e('ZERO'); // 测试设置 array(1) 的默认参数
r($search->setDefaultParamsTest($fields7, $params7)) && p('0') && e('0'); // 测试设置 nonull 的默认参数
r($search->setDefaultParamsTest($fields7, $params7)) && p('0') && e('0'); // 测试设置 nonull 的默认参数
+15 -10
View File
@@ -12,13 +12,15 @@ timeout=0
cid=1
- 测试module的值属性module @bug
- 测试searchFields的值属性searchFields @{"title":"Bug Title"}
- 测试fieldParams的值
- 属性fieldParams @{"title":{"operator":"include"\\
- 测试actionURL的值属性actionURL @/index.php?m=bug&f=browse&productID=110&branch=0&browseType=bySearch&queryID=myQueryID
- 测试onMenuBar的值属性onMenuBar @yes
- 测试queryID的值属性queryID @0
- 测试style的值属性style @full
- 测试searchFields的值属性title @Bug Title
- 测试fieldParams的值
- 第title条的operator属性 @include
- 第title条的control属性 @input
- 第title条的value属性 @~~
*/
@@ -36,10 +38,13 @@ $searchConfig['onMenuBar'] = 'yes';
$searchConfig['actionURL'] = '/index.php?m=bug&f=browse&productID=110&branch=0&browseType=bySearch&queryID=myQueryID';
$searchConfig['queryID'] = 0;
r($search->setSearchParams($searchConfig)) && p('module') && e('bug'); //测试module的值
r($search->setSearchParams($searchConfig)) && p('searchFields') && e('{"title":"Bug Title"}'); //测试searchFields的值
r($search->setSearchParams($searchConfig)) && p('fieldParams', ';') && e('{"title":{"operator":"include","control":"input","value":""}}'); //测试fieldParams的值
r($search->setSearchParams($searchConfig)) && p('actionURL') && e('/index.php?m=bug&f=browse&productID=110&branch=0&browseType=bySearch&queryID=myQueryID'); //测试actionURL的值
r($search->setSearchParams($searchConfig)) && p('onMenuBar') && e('yes'); //测试onMenuBar的值
r($search->setSearchParams($searchConfig)) && p('queryID') && e('0'); //测试queryID的值
r($search->setSearchParams($searchConfig)) && p('style') && e('full'); //测试style的值
$result = $search->setSearchParams($searchConfig);
r($result) && p('module') && e('bug'); //测试module的值
r($result) && p('actionURL') && e('/index.php?m=bug&f=browse&productID=110&branch=0&browseType=bySearch&queryID=myQueryID'); //测试actionURL的值
r($result) && p('onMenuBar') && e('yes'); //测试onMenuBar的值
r($result) && p('queryID') && e('0'); //测试queryID的值
r($result) && p('style') && e('full'); //测试style的值
r($result['fields']) && p('title') && e('Bug Title'); //测试searchFields的值
r($result['params']) && p('title:operator,control,value') && e('include,input,~~'); //测试fieldParams的值
@@ -8,21 +8,21 @@ timeout=0
cid=1
- 测试 andOr,operator,value 的值
- 属性andOr @AND
- 属性operator @include
- 属性value @测试
- @AND
- 属性1 @include
- 属性2 @测试
- 测试 andOr,operator,value 的值
- 属性andOr @OR
- 属性operator @=
- 属性value @1
- @OR
- 属性1 @=
- 属性2 @1
- 测试 andOr,operator,value 的值
- 属性andOr @AND
- 属性operator @=
- 属性value @~~
- @AND
- 属性1 @=
- 属性2 @~~
- 测试 andOr,operator,value 的值
- 属性andOr @AND
- 属性operator @=
- 属性value @0
- @AND
- 属性1 @=
- 属性2 @0
*/
@@ -31,38 +31,19 @@ include dirname(__FILE__, 2) . '/lib/search.unittest.class.php';
su('admin');
$fields = array('title', 'id', 'status', 'activatedCount');
$andOrName = 'andOr1';
$operatorName = 'operator1';
$valueName = 'value1';
$postDatas = array();
$postData1 = new stdClass();
$postData1->$andOrName = 'and';
$postData1->$operatorName = 'include';
$postData1->$valueName = '测试';
$postDatas[] =[$andOrName => 'and', $operatorName => 'include', $valueName => '测试'];
$postDatas[] =[$andOrName => 'or', $operatorName => '=', $valueName => '1'];
$postDatas[] =[$andOrName => '', $operatorName => ''];
$postDatas[] =[$andOrName => '', $operatorName => '', $valueName => 'ZERO'];
$postData2 = new stdClass();
$postData2->$andOrName = 'or';
$postData2->$operatorName = '=';
$postData2->$valueName = '1';
$postData3 = new stdClass();
$postData3->$andOrName = '';
$postData3->$operatorName = '';
$postData4 = new stdClass();
$postData4->$andOrName = '';
$postData4->$operatorName = '';
$postData4->$valueName = 'ZERO';
$postDatas[] = $postData1;
$postDatas[] = $postData2;
$postDatas[] = $postData3;
$postDatas[] = $postData4;
$fields = array('title', 'id', 'status', 'activatedCount');
$search = new searchTest();
r($search->processQueryFormDatasTest($postDatas[0], $fields[0], $andOrName, $operatorName, $valueName)) && p('andOr,operator,value') && e('AND,include,测试'); //测试 andOr,operator,value 的值
r($search->processQueryFormDatasTest($postDatas[1], $fields[1], $andOrName, $operatorName, $valueName)) && p('andOr,operator,value') && e('OR,=,1'); //测试 andOr,operator,value 的值
r($search->processQueryFormDatasTest($postDatas[2], $fields[2], $andOrName, $operatorName, $valueName)) && p('andOr,operator,value') && e('AND,=,~~'); //测试 andOr,operator,value 的值
r($search->processQueryFormDatasTest($postDatas[3], $fields[3], $andOrName, $operatorName, $valueName)) && p('andOr,operator,value') && e('AND,=,0'); //测试 andOr,operator,value 的值
r($search->processQueryFormDatasTest($postDatas[0], $fields[0], $andOrName, $operatorName, $valueName)) && p('0,1,2') && e('AND,include,测试'); // 测试 andOr,operator,value 的值
r($search->processQueryFormDatasTest($postDatas[1], $fields[1], $andOrName, $operatorName, $valueName)) && p('0,1,2') && e('OR,=,1'); // 测试 andOr,operator,value 的值
r($search->processQueryFormDatasTest($postDatas[2], $fields[2], $andOrName, $operatorName, $valueName)) && p('0,1,2') && e('AND,=,~~'); // 测试 andOr,operator,value 的值
r($search->processQueryFormDatasTest($postDatas[3], $fields[3], $andOrName, $operatorName, $valueName)) && p('0,1,2') && e('AND,=,0'); // 测试 andOr,operator,value 的值