From bcc8fab1a214e2186b2acb23d72591d1968d30df Mon Sep 17 00:00:00 2001 From: wangxuepeng Date: Wed, 20 Sep 2023 05:41:39 +0000 Subject: [PATCH] * Fixed unit test of getdynamicbysearch method of the action module. --- module/action/model.php | 17 +++--------- .../action/test/model/getdynamicbysearch.php | 26 ++++++++++--------- .../model/yaml/getdynamicbysearch/action.yaml | 2 +- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/module/action/model.php b/module/action/model.php index 3a8fa122c5..4ca0eddace 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -1257,24 +1257,15 @@ class actionModel extends model /* 如果sql语句中不包含'prodcut', 则添加产品权限检查。 */ /* If the sql not include 'product', add check purview for product. */ - if(strpos($actionQuery, $allProducts) !== false) - { - $actionQuery = str_replace($allProducts, '1', $actionQuery); - } + if(strpos($actionQuery, $allProducts) !== false) $actionQuery = str_replace($allProducts, '1', $actionQuery); /* 如果sql语句中不包含'project', 则添加项目权限检查。 */ /* If the sql not include 'project', add check purview for project. */ - if(strpos($actionQuery, $allProjects) !== false) - { - $actionQuery = str_replace($allProjects, '1', $actionQuery); - } + if(strpos($actionQuery, $allProjects) !== false) $actionQuery = str_replace($allProjects, '1', $actionQuery); /* 如果sql语句中不包含'execution', 则添加执行权限检查。 */ /* If the sql not include 'execution', add check purview for execution. */ - if(strpos($actionQuery, $allExecutions) !== false) - { - $actionQuery = str_replace($allExecutions, '1', $actionQuery); - } + if(strpos($actionQuery, $allExecutions) !== false) $actionQuery = str_replace($allExecutions, '1', $actionQuery); $actionQuery = str_replace("`product` = '$productID'", "`product` LIKE '%,$productID,%'", $actionQuery); @@ -1286,7 +1277,7 @@ class actionModel extends model $actionQuery .= " AND vision = '" . $this->config->vision . "'"; $actions = $this->getBySQL($actionQuery, $orderBy, $pager); - + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'action'); if(!$actions) return array(); return $this->transformActions($actions); diff --git a/module/action/test/model/getdynamicbysearch.php b/module/action/test/model/getdynamicbysearch.php index e947fdc778..878892c123 100755 --- a/module/action/test/model/getdynamicbysearch.php +++ b/module/action/test/model/getdynamicbysearch.php @@ -4,10 +4,10 @@ include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/action.class.php'; su('admin'); -zdTable('action')->gen(90); -zdTable('doclib')->config('doclib')->gen(15); -zdTable('doc')->config('doc')->gen(5); -zdTable('product')->gen(15); +zdTable('action')->config('action')->gen(90); +zdTable('doclib')->gen(1); +zdTable('doc')->gen(1); +zdTable('product')->gen(1); zdTable('userquery')->config('userquery')->gen(1); /** @@ -16,10 +16,11 @@ title=测试 actionModel->getDynamicBySearch(); cid=1 pid=1 -获取排序为date倒序的所有动态 >> 32,testcase -获取排序为date倒序的所有动态 >> 1,product -获取排序为date正序的今天之前的动态 >> 32,testcase -获取queryID为1,排序为date倒序的今天之后的动态 >> 1,product +获取排序为date倒序的所有动态 >> 64,testsuite;32,testcase +获取排序为date正序的所有动态 >> 65,caselib;1,product +获取排序为date倒序的今年之后的动态 >> 64,testsuite;32,testcase +获取排序为date倒序的今天之前的动态 >> 63,module;31,bug +获取排序为date倒序的今年之后的动态 >> 1,product */ @@ -31,7 +32,8 @@ $directionList = array('next', 'pre'); $action = new actionTest(); -r($action->getDynamicBySearchTest($queryID[0], $orderByList[0], $pager, $dateList[0], $directionList[0])) && p('1:id,objectType') && e('32,testcase'); // 获取product all, project all, execution all排序为date倒序的所有动态 -r($action->getDynamicBySearchTest($queryID[0], $orderByList[1], $pager, $dateList[0], $directionList[0])) && p('1:id,objectType') && e('1,product'); // 获取product all, project all, execution all排序为date正序的所有动态 -r($action->getDynamicBySearchTest($queryID[0], $orderByList[0], $pager, $dateList[0], $directionList[1])) && p('1:id,objectType') && e('32,testcase'); // 获取product all, project all, execution all排序为date倒序的今天之后的动态 -r($action->getDynamicBySearchTest($queryID[1], $orderByList[0], $pager, $dateList[0], $directionList[1])) && p('0:id,objectType') && e('1,product'); // 获取product all, project all, execution all排序为date倒序的今天之后的动态 +r($action->getDynamicBySearchTest($queryID[0], $orderByList[0], $pager, $dateList[0], $directionList[0])) && p('0:id,objectType;1:id,objectType') && e('64,testsuite;32,testcase'); // 获取排序为date倒序的所有动态 +r($action->getDynamicBySearchTest($queryID[0], $orderByList[1], $pager, $dateList[0], $directionList[0])) && p('0:id,objectType;1:id,objectType') && e('65,caselib;1,product'); // 获取排序为date正序的所有动态 +r($action->getDynamicBySearchTest($queryID[0], $orderByList[0], $pager, $dateList[0], $directionList[1])) && p('0:id,objectType;1:id,objectType') && e('64,testsuite;32,testcase'); // 获取排序为date倒序的今年之后的动态 +r($action->getDynamicBySearchTest($queryID[0], $orderByList[0], $pager, $dateList[1], $directionList[0])) && p('0:id,objectType;1:id,objectType') && e('63,module;31,bug'); // 获取排序为date倒序的今天之前的动态 +r($action->getDynamicBySearchTest($queryID[1], $orderByList[0], $pager, $dateList[0], $directionList[1])) && p('0:id,objectType') && e('1,product'); // 获取排序为date倒序的今年之后的动态 diff --git a/module/action/test/model/yaml/getdynamicbysearch/action.yaml b/module/action/test/model/yaml/getdynamicbysearch/action.yaml index e24923b2e4..3c4b3ecafa 100644 --- a/module/action/test/model/yaml/getdynamicbysearch/action.yaml +++ b/module/action/test/model/yaml/getdynamicbysearch/action.yaml @@ -12,7 +12,7 @@ fields: format: "" - field: objectID note: "对象ID" - range: "1-100000" + range: 1 prefix: "" postfix: "" loop: 0