From 8ee1730ea29ff83158d033ec1f57c109ec83d5fb Mon Sep 17 00:00:00 2001 From: liugang Date: Fri, 7 Nov 2025 19:10:43 +0800 Subject: [PATCH] + [misc] Add unit tests for bugZen::assignKanbanVars() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- module/bug/test/lib/zen.class.php | 23 +++ module/bug/test/zen/assignkanbanvars.php | 72 +++++++ .../zen/yaml/assignkanbanvars/kanban.yaml | 182 ++++++++++++++++++ .../yaml/assignkanbanvars/kanbangroup.yaml | 49 +++++ .../zen/yaml/assignkanbanvars/kanbanlane.yaml | 84 ++++++++ .../yaml/assignkanbanvars/kanbanregion.yaml | 63 ++++++ .../zen/yaml/assignkanbanvars/project.yaml | 63 ++++++ 7 files changed, 536 insertions(+) create mode 100755 module/bug/test/zen/assignkanbanvars.php create mode 100644 module/bug/test/zen/yaml/assignkanbanvars/kanban.yaml create mode 100644 module/bug/test/zen/yaml/assignkanbanvars/kanbangroup.yaml create mode 100644 module/bug/test/zen/yaml/assignkanbanvars/kanbanlane.yaml create mode 100644 module/bug/test/zen/yaml/assignkanbanvars/kanbanregion.yaml create mode 100644 module/bug/test/zen/yaml/assignkanbanvars/project.yaml diff --git a/module/bug/test/lib/zen.class.php b/module/bug/test/lib/zen.class.php index 3da02ff938..ea05ecb851 100644 --- a/module/bug/test/lib/zen.class.php +++ b/module/bug/test/lib/zen.class.php @@ -88,4 +88,27 @@ class bugZenTest extends baseTest if(dao::isError()) return false; return true; } + + /** + * Test assignKanbanVars method. + * + * @param object $execution + * @param array $output + * @access public + * @return array + */ + public function assignKanbanVarsTest(object $execution, array $output = array()): array + { + $instance = $this->getInstance($this->moduleName, $this->className); + $this->invokeArgs('assignKanbanVars', [$execution, $output]); + if(dao::isError()) return array(); + + return array( + 'executionType' => $instance->view->executionType ?? '', + 'regionID' => $instance->view->regionID ?? 0, + 'laneID' => $instance->view->laneID ?? 0, + 'regionPairs' => !empty($instance->view->regionPairs) ? count($instance->view->regionPairs) : 0, + 'lanePairs' => !empty($instance->view->lanePairs) ? count($instance->view->lanePairs) : 0, + ); + } } diff --git a/module/bug/test/zen/assignkanbanvars.php b/module/bug/test/zen/assignkanbanvars.php new file mode 100755 index 0000000000..e1b363d628 --- /dev/null +++ b/module/bug/test/zen/assignkanbanvars.php @@ -0,0 +1,72 @@ +#!/usr/bin/env php +loadYaml('assignkanbanvars/project', false, 2)->gen(10); +zenData('kanbanregion')->loadYaml('assignkanbanvars/kanbanregion', false, 2)->gen(20); +zenData('kanbanlane')->loadYaml('assignkanbanvars/kanbanlane', false, 2)->gen(30); +zenData('kanbangroup')->loadYaml('assignkanbanvars/kanbangroup', false, 2)->gen(10); + +su('admin'); + +$bugTest = new bugZenTest(); + +$execution1 = new stdclass(); +$execution1->id = 1; +$execution1->type = 'kanban'; + +$execution2 = new stdclass(); +$execution2->id = 2; +$execution2->type = 'sprint'; + +$execution3 = new stdclass(); +$execution3->id = 3; +$execution3->type = 'stage'; + +$execution4 = new stdclass(); +$execution4->id = 4; +$execution4->type = 'kanban'; + +$execution5 = new stdclass(); +$execution5->id = 5; +$execution5->type = 'sprint'; + +$execution99 = new stdclass(); +$execution99->id = 99; +$execution99->type = 'kanban'; + +r($bugTest->assignKanbanVarsTest($execution1, array())) && p('executionType') && e('kanban'); // 测试看板类型执行无output参数情况 +r($bugTest->assignKanbanVarsTest($execution2, array())) && p('executionType') && e('sprint'); // 测试sprint类型执行无output参数情况 +r($bugTest->assignKanbanVarsTest($execution3, array('regionID' => 5))) && p('executionType,regionID') && e('stage,5'); // 测试stage类型执行有regionID参数情况 +r($bugTest->assignKanbanVarsTest($execution4, array('groupID' => 2))) && p('executionType') && e('kanban'); // 测试有groupID参数情况 +r($bugTest->assignKanbanVarsTest($execution5, array('regionID' => 3, 'laneID' => 10))) && p('executionType,regionID,laneID') && e('sprint,3,10'); // 测试有regionID和laneID参数情况 +r($bugTest->assignKanbanVarsTest($execution99, array())) && p('executionType,regionID') && e('kanban,0'); // 测试无区域数据情况 +r($bugTest->assignKanbanVarsTest($execution1, array('regionID' => 99))) && p('executionType,regionID,laneID') && e('kanban,99,0'); // 测试无泳道数据情况 \ No newline at end of file diff --git a/module/bug/test/zen/yaml/assignkanbanvars/kanban.yaml b/module/bug/test/zen/yaml/assignkanbanvars/kanban.yaml new file mode 100644 index 0000000000..be76dee3d5 --- /dev/null +++ b/module/bug/test/zen/yaml/assignkanbanvars/kanban.yaml @@ -0,0 +1,182 @@ +--- +title: kanban表数据定义 +desc: 为assignKanbanVars方法测试准备kanban数据 +author: Claude Code +version: 1.0 + +fields: +- field: id + note: 看板ID + range: 1-10 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: space + note: 空间ID + range: 1-5 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: name + note: 看板名称 + range: "Kanban{1-10}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: owner + note: 所有者 + range: "admin,user1,user2" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: team + note: 团队 + range: "[]" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: status + note: 状态 + range: "active{8},closed{2}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: acl + note: 访问控制 + range: "open{5},private{3},custom{2}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: whitelist + note: 白名单 + range: "[]" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: order + note: 排序 + range: 1-10 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: displayCards + note: 显示卡片数 + range: 0-20 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: fluidBoard + note: 流式看板 + range: "0{5},1{5}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: colWidth + note: 列宽 + range: 264-320 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: minColWidth + note: 最小列宽 + range: 200-264 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: maxColWidth + note: 最大列宽 + range: 320-400 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: object + note: 对象类型 + range: "execution{10}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: alignment + note: 对齐方式 + range: "center,left,right" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: createdBy + note: 创建者 + range: "admin,user1,user2" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: createdDate + note: 创建时间 + range: "2023-01-01 00:00:00-2023-12-31 23:59:59" + prefix: "" + postfix: "" + loop: 0 + format: "YYYY-MM-DD hh:mm:ss" +- field: lastEditedBy + note: 最后编辑者 + range: "admin,user1,user2,[]" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: lastEditedDate + note: 最后编辑时间 + range: "2023-01-01 00:00:00-2023-12-31 23:59:59,0000-00-00 00:00:00" + prefix: "" + postfix: "" + loop: 0 + format: "YYYY-MM-DD hh:mm:ss" +- field: closedBy + note: 关闭者 + range: "admin,user1,[]{7}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: closedDate + note: 关闭时间 + range: "2023-01-01 00:00:00-2023-12-31 23:59:59,0000-00-00 00:00:00{7}" + prefix: "" + postfix: "" + loop: 0 + format: "YYYY-MM-DD hh:mm:ss" +- field: activatedBy + note: 激活者 + range: "admin,[]{9}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: activatedDate + note: 激活时间 + range: "2023-01-01 00:00:00-2023-12-31 23:59:59,0000-00-00 00:00:00{9}" + prefix: "" + postfix: "" + loop: 0 + format: "YYYY-MM-DD hh:mm:ss" +- field: deleted + note: 删除状态 + range: "0{9},1{1}" + prefix: "" + postfix: "" + loop: 0 + format: "" diff --git a/module/bug/test/zen/yaml/assignkanbanvars/kanbangroup.yaml b/module/bug/test/zen/yaml/assignkanbanvars/kanbangroup.yaml new file mode 100644 index 0000000000..93091ce057 --- /dev/null +++ b/module/bug/test/zen/yaml/assignkanbanvars/kanbangroup.yaml @@ -0,0 +1,49 @@ +--- +title: kanbangroup表数据定义 +desc: 为assignKanbanVars方法测试准备kanban分组数据 +author: Claude Code +version: 1.0 + +fields: +- field: id + note: 分组ID + range: 1-10 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: kanban + note: 看板ID + range: 1-10 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: region + note: 区域ID + range: 1-20 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: name + note: 分组名称 + range: "Group{1-10}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: order + note: 排序 + range: 1-10 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: deleted + note: 删除状态 + range: "0{9},1{1}" + prefix: "" + postfix: "" + loop: 0 + format: "" diff --git a/module/bug/test/zen/yaml/assignkanbanvars/kanbanlane.yaml b/module/bug/test/zen/yaml/assignkanbanvars/kanbanlane.yaml new file mode 100644 index 0000000000..b6bc7913d0 --- /dev/null +++ b/module/bug/test/zen/yaml/assignkanbanvars/kanbanlane.yaml @@ -0,0 +1,84 @@ +--- +title: kanbanlane表数据定义 +desc: 为assignKanbanVars方法测试准备kanban泳道数据 +author: Claude Code +version: 1.0 + +fields: +- field: id + note: 泳道ID + range: 1-30 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: execution + note: 执行ID + range: 0 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: type + note: 泳道类型 + range: "bug{30}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: region + note: 所属区域ID + range: 1-20{2} + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: group + note: 分组ID + range: 0,1-5 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: groupby + note: 分组方式 + range: "default{20},story{5},module{5}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: name + note: 泳道名称 + range: "Lane{1-30}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: order + note: 排序 + range: 1-30 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: color + note: 颜色 + range: "#FF5722,#4CAF50,#2196F3,#9C27B0,#FF9800" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: lastEditedTime + note: 最后编辑时间 + range: "2023-01-01 00:00:00-2023-12-31 23:59:59" + prefix: "" + postfix: "" + loop: 0 + format: "YYYY-MM-DD hh:mm:ss" +- field: deleted + note: 删除状态 + range: "0{29},1{1}" + prefix: "" + postfix: "" + loop: 0 + format: "" diff --git a/module/bug/test/zen/yaml/assignkanbanvars/kanbanregion.yaml b/module/bug/test/zen/yaml/assignkanbanvars/kanbanregion.yaml new file mode 100644 index 0000000000..6d3d74f185 --- /dev/null +++ b/module/bug/test/zen/yaml/assignkanbanvars/kanbanregion.yaml @@ -0,0 +1,63 @@ +--- +title: kanbanregion表数据定义 +desc: 为assignKanbanVars方法测试准备kanban区域数据 +author: Claude Code +version: 1.0 + +fields: +- field: id + note: 区域ID + range: 1-20 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: space + note: 空间ID + range: 0 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: kanban + note: 看板ID(对应execution ID) + range: 1-10 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: name + note: 区域名称 + range: "Region{1-20}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: order + note: 排序 + range: 1-20 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: createdBy + note: 创建者 + range: "admin,user1,user2" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: createdDate + note: 创建时间 + range: "2023-01-01 00:00:00-2023-12-31 23:59:59" + prefix: "" + postfix: "" + loop: 0 + format: "YYYY-MM-DD hh:mm:ss" +- field: deleted + note: 删除状态 + range: "0{19},1{1}" + prefix: "" + postfix: "" + loop: 0 + format: "" diff --git a/module/bug/test/zen/yaml/assignkanbanvars/project.yaml b/module/bug/test/zen/yaml/assignkanbanvars/project.yaml new file mode 100644 index 0000000000..3b28e1531a --- /dev/null +++ b/module/bug/test/zen/yaml/assignkanbanvars/project.yaml @@ -0,0 +1,63 @@ +--- +title: project表数据定义 +desc: 为assignKanbanVars方法测试准备project数据 +author: Claude Code +version: 1.0 + +fields: +- field: id + note: 项目ID + range: 1-10 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: name + note: 项目名称 + range: "Project{1-10}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: type + note: 项目类型 + range: "project{5},program{3},sprint{2}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: status + note: 项目状态 + range: "wait{3},doing{5},done{2}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: model + note: 项目模型 + range: "scrum{5},waterfall{3},kanban{2}" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: openedBy + note: 创建者 + range: "admin,user1,user2" + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: openedDate + note: 创建时间 + range: "2023-01-01 00:00:00-2023-12-31 23:59:59" + prefix: "" + postfix: "" + loop: 0 + format: "YYYY-MM-DD hh:mm:ss" +- field: deleted + note: 删除状态 + range: "0{9},1{1}" + prefix: "" + postfix: "" + loop: 0 + format: ""