From 0a3496603a936f2a53e5f53c4007b1576d92e9bb Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 11 Sep 2025 17:05:26 +0800 Subject: [PATCH 1/3] * [misc] Fix unittest error of the searchModel::setSearchParams() method. --- module/search/test/model/setsearchparams.php | 25 ++++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/module/search/test/model/setsearchparams.php b/module/search/test/model/setsearchparams.php index 29ce3a71ee..763049266e 100755 --- a/module/search/test/model/setsearchparams.php +++ b/module/search/test/model/setsearchparams.php @@ -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的值 \ No newline at end of file From 9803666fb8220e7b5ef11c52258cbd56a9576db8 Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 11 Sep 2025 17:23:18 +0800 Subject: [PATCH 2/3] * [misc] Fix unittest error of the searchModel::setDefaultParams() method. --- module/search/test/model/setdefaultparams.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/module/search/test/model/setdefaultparams.php b/module/search/test/model/setdefaultparams.php index eee3ef7fe6..ef257afca5 100755 --- a/module/search/test/model/setdefaultparams.php +++ b/module/search/test/model/setdefaultparams.php @@ -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 的默认参数 \ No newline at end of file From bac6c954e1ff56ad26c75eaf3cfbfdabc8e281f0 Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 11 Sep 2025 17:41:37 +0800 Subject: [PATCH 3/3] * [misc] Fix unittest error of the searchTao::processQueryFormDatas() method. --- .../search/test/lib/search.unittest.class.php | 20 ++---- .../search/test/tao/processqueryformdatas.php | 61 +++++++------------ 2 files changed, 25 insertions(+), 56 deletions(-) diff --git a/module/search/test/lib/search.unittest.class.php b/module/search/test/lib/search.unittest.class.php index a8754ad501..d0354966cb 100755 --- a/module/search/test/lib/search.unittest.class.php +++ b/module/search/test/lib/search.unittest.class.php @@ -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); } /** diff --git a/module/search/test/tao/processqueryformdatas.php b/module/search/test/tao/processqueryformdatas.php index 7ad2ddc186..1305f55d39 100755 --- a/module/search/test/tao/processqueryformdatas.php +++ b/module/search/test/tao/processqueryformdatas.php @@ -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 的值