* Fixed unit test of getdynamicbysearch method of the action module.

This commit is contained in:
wangxuepeng
2023-09-20 05:41:45 +00:00
parent d627debb85
commit bcc8fab1a2
3 changed files with 19 additions and 26 deletions
+4 -13
View File
@@ -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);
+14 -12
View File
@@ -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倒序的今年之后的动态
@@ -12,7 +12,7 @@ fields:
format: ""
- field: objectID
note: "对象ID"
range: "1-100000"
range: 1
prefix: ""
postfix: ""
loop: 0