From eba1d7cdce401e3caa18b4aa61409576142f08ff Mon Sep 17 00:00:00 2001 From: wangxuepeng Date: Mon, 25 Sep 2023 02:10:31 +0000 Subject: [PATCH] * Add unit test for action processObjectActions. --- module/action/model.php | 6 +++-- module/action/test/action.class.php | 1 + module/action/test/model/getdynamic.php | 2 +- .../test/model/processdynamicforapi.php | 8 ++++--- .../test/model/processprojectactions.php | 22 ++++++++----------- .../yaml/processprojectactions/action.yaml | 18 +++++++++++++++ 6 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 module/action/test/model/yaml/processprojectactions/action.yaml diff --git a/module/action/model.php b/module/action/model.php index daf3b57b95..3f24ed6f91 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -611,7 +611,7 @@ class actionModel extends model } /** - * 修改项目的动作为项目的操作类型。 + * 将项目行动类型转换为通用行动类型。 * Process Project Actions change actionStype. * * @param array $actions @@ -2392,6 +2392,8 @@ class actionModel extends model */ public function processDynamicForAPI($dynamics): array { + /* 获取用户列表。 */ + /* Get user list. */ $users = $this->loadModel('user')->getList(); $simplifyUsers = array(); foreach($users as $user) @@ -2407,7 +2409,7 @@ class actionModel extends model $actions = array(); foreach($dynamics as $dynamic) { - if($dynamic->objectType == 'user') continue; + if($dynamic->objectType == 'user') continue; //过滤掉用户动态。 $simplifyUser = zget($simplifyUsers, $dynamic->actor, ''); $actor = $simplifyUser; diff --git a/module/action/test/action.class.php b/module/action/test/action.class.php index be95ec1471..644318a72c 100644 --- a/module/action/test/action.class.php +++ b/module/action/test/action.class.php @@ -120,6 +120,7 @@ class actionTest } /** + * 测试将项目日志类型转换为动态类型。 * Test process Project Actions change actionStype. * * @param array $actions diff --git a/module/action/test/model/getdynamic.php b/module/action/test/model/getdynamic.php index 4cc3d51b6f..da98a4c956 100755 --- a/module/action/test/model/getdynamic.php +++ b/module/action/test/model/getdynamic.php @@ -50,7 +50,7 @@ r($action->getDynamicTest($accountList[2])) r($action->getDynamicTest($accountList[3])) && p() && e('10'); // 查找用户test18动态 r($action->getDynamicTest($accountList[0], $typeList[1])) && p() && e('0'); // 查找今天的动态 r($action->getDynamicTest($accountList[0], $typeList[2])) && p() && e('0'); // 查找昨天的动态 -r($action->getDynamicTest($accountList[0], $typeList[3])) && p() && e('7'); // 查找上周的动态 +r($action->getDynamicTest($accountList[0], $typeList[3])) && p() && e('6'); // 查找上周的动态 r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[1])) && p() && e('1'); // 查找产品1的动态 r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[2])) && p() && e('1'); // 查找产品2的动态 r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[3])) && p() && e('1'); // 查找产品3的动态 diff --git a/module/action/test/model/processdynamicforapi.php b/module/action/test/model/processdynamicforapi.php index 62d5a92130..e09d6ba898 100755 --- a/module/action/test/model/processdynamicforapi.php +++ b/module/action/test/model/processdynamicforapi.php @@ -4,6 +4,8 @@ include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/action.class.php'; su('admin'); +zdTable('action')->gen(10); + /** title=测试 actionModel->processDynamicForAPI(); @@ -11,7 +13,7 @@ cid=1 pid=1 测试处理空数据 >> 0 -处理所有动态 >> admin,admin,/home/z/tmp/1.png +处理所有动态 >> 1,admin,admin */ @@ -19,5 +21,5 @@ $action = new actionTest(); $dynamics = $tester->dao->select('*')->from(TABLE_ACTION)->fetchAll(); -r($action->processDynamicForAPITest(array())) && p() && e('0'); // 测试处理空数据 -r($action->processDynamicForAPITest($dynamics)) && p('actor:account,realname,avatar') && e('admin,admin,/home/z/tmp/1.png'); // 处理所有动态 +r($action->processDynamicForAPITest(array())) && p() && e('0'); // 测试处理空数据 +r($action->processDynamicForAPITest($dynamics)) && p('actor:id,account,realname') && e('1,admin,admin'); // 处理所有动态 diff --git a/module/action/test/model/processprojectactions.php b/module/action/test/model/processprojectactions.php index c5bb83e481..0f64ead413 100755 --- a/module/action/test/model/processprojectactions.php +++ b/module/action/test/model/processprojectactions.php @@ -4,28 +4,24 @@ include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/action.class.php'; su('admin'); +zdTable('action')->config('action')->gen(10); + /** title=测试 actionModel->processProjectActions(); cid=1 pid=1 -测试计算action 1 2 3 4 5 的项目动态 >> 5 -测试计算action 26 27 28 29 30 的项目动态 >> 28 -测试计算action 51 52 53 54 55 的项目动态 >> 51 -测试计算action 71 72 73 74 75 的项目动态 >> 74 -测试计算action 96 97 98 99 100 的项目动态 >> 97 -测试计算action 5 28 51 74 97 的项目动态 >> 5,28,51,74,97 +测试计算action 1 2 3 4 5 的项目动态 >> 0 +测试计算action 6 7 8 9 10 的项目动态 >> 5 +测试计算action 11 12 13 14 15 的项目动态 >> 0 */ -$actions = array('1,2,3,4,5', '26,27,28,29,30', '51,52,53,54,55', '71,72,73,74,75', '96,97,98,99,100', '5,28,51,74,97'); +$actions = array('1,2,3,4,5', '6,7,8,9,10', '11,12,13,14,15'); $action = new actionTest(); -r($action->processProjectActionsTest($actions[0])) && p() && e('5'); // 测试计算action 1 2 3 4 5 的项目动态 -r($action->processProjectActionsTest($actions[1])) && p() && e('28'); // 测试计算action 26 27 28 29 30 的项目动态 -r($action->processProjectActionsTest($actions[2])) && p() && e('51'); // 测试计算action 51 52 53 54 55 的项目动态 -r($action->processProjectActionsTest($actions[3])) && p() && e('74'); // 测试计算action 71 72 73 74 75 的项目动态 -r($action->processProjectActionsTest($actions[4])) && p() && e('97'); // 测试计算action 96 97 98 99 100 的项目动态 -r($action->processProjectActionsTest($actions[5])) && p() && e('5,28,51,74,97'); // 测试计算action 5 28 51 74 97 的项目动态 \ No newline at end of file +r($action->processProjectActionsTest($actions[0])) && p() && e('0'); // 测试计算action 1 2 3 4 5 的项目动态 >> 0 +r($action->processProjectActionsTest($actions[1])) && p() && e('7,8,9,10'); // 测试计算action 6 7 8 9 10 的项目动态 >> 5 +r($action->processProjectActionsTest($actions[2])) && p() && e('0'); // 测试计算action 11 12 13 14 15 的项目动态 >> 0 diff --git a/module/action/test/model/yaml/processprojectactions/action.yaml b/module/action/test/model/yaml/processprojectactions/action.yaml new file mode 100644 index 0000000000..3aaa318aba --- /dev/null +++ b/module/action/test/model/yaml/processprojectactions/action.yaml @@ -0,0 +1,18 @@ +title: table zt_action +desc: "系统日志" +author: automated export +version: "1.0" +fields: + - field: objectType + note: "对象类型" + range: product{6},testtask{3},build,project,user,testsuite + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: action + note: "动作" + range: common{6},opened,started,closed,opened + postfix: "" + loop: 0 + format: ""