diff --git a/module/programplan/test/model/computeprogress.php b/module/programplan/test/model/computeprogress.php new file mode 100755 index 0000000000..cef17611d4 --- /dev/null +++ b/module/programplan/test/model/computeprogress.php @@ -0,0 +1,35 @@ +#!/usr/bin/env php +config('project')->gen(9); + zdTable('task')->config('task')->gen(9); +} + +/** + +title=测试 programplanModel->computeProgress(); +timeout=0 +cid=1 + +- 测试参数=项目id直接返回false @fail + +- 测试阶段有子阶段 @success + +- 测试阶段有子阶段状态更新为donging属性status @doing + +*/ + +initData(); + +$programplan = new programplanTest(); + +r($programplan->computeProgressTest('3', 'edit', false)) && p() && e('fail'); // 测试参数=项目id直接返回false +r($programplan->computeProgressTest('4', 'edit', true)) && p() && e('success'); // 测试阶段有子阶段 +r($programplan->getByIdTest(4)) && p('status') && e('doing'); // 测试阶段有子阶段状态更新为donging +r($programplan->computeProgressTest('9', 'edit', true)) && p() && e('success'); // 测试子阶段有子阶段 +r($programplan->getByIdTest(7)) && p('status') && e('doing'); // 测试子阶段有子阶段状态更新为donging diff --git a/module/programplan/test/model/yaml/computeprogress/project.yaml b/module/programplan/test/model/yaml/computeprogress/project.yaml new file mode 100644 index 0000000000..e97485ca6b --- /dev/null +++ b/module/programplan/test/model/yaml/computeprogress/project.yaml @@ -0,0 +1,24 @@ +title: zt_project +author: liuchenglong +version: "1.0" +fields: + - field: id + range: 1-9 + - field: project + range: 0, 1, 0, 3, 3, 3, 3, 3, 3 + - field: model + range: 'scrum, ,waterfall, , ,scrum' + - field: type + range: 'project,sprint,project,stage,stage,stage,stage,stage,stage' + - field: status + range: 'wait,doing,closed,suspended' + - field: parent + range: 0, 1, 0, 3, 4, 4, 4, 4, 7 + - field: path + range: '`,1,`, `,1,2,`, `,3,`, `,3,4,`, `,3,4,5,`, `,3,4,6,`, `,3,4,7,`, `,3,4,8,`, `,3,4,7,9,`' + - field: hasProduct + range: 1, 1, 1, 1, 1, 0 + - field: name + range: '项目1, 执行1-2, 项目3, 执行3-4, 执行3-4-5, 执行3-4-6, 执行3-4-7, 执行3-4-8, 执行3-4-7-9' + - field: code + range: 'project1, sprint1-2, project3, sprint3-4, sprint3-4-5, psprint3-4-6, sprint3-4-7, sprint3-4-8, spring3-4-7-9' diff --git a/module/programplan/test/model/yaml/computeprogress/task.yaml b/module/programplan/test/model/yaml/computeprogress/task.yaml new file mode 100644 index 0000000000..d98b9321b8 --- /dev/null +++ b/module/programplan/test/model/yaml/computeprogress/task.yaml @@ -0,0 +1,20 @@ +title: zt_task +author: liuchenglong +version: "1.0" +fields: + - field: id + range: 1-20 + - field: execution + range: 1-20 + - field: type + range: design,devel,test,study,discuss,ui,affair,misc + - field: status + range: wait{20} + - field: deleted + range: 0,1,1,0 + - field: vision + range: rnd,rnd,rnd,lite + - field: openedDate + range: "20220101 000000:1W" # 生成从2021年1月1日0时0分0秒到当前时间的数据,步长为1周 + type: timestamp + format: "YY/MM/DD hh:mm:ss" diff --git a/module/programplan/test/programplan.class.php b/module/programplan/test/programplan.class.php index 7313a3e120..d5bb5a2ecc 100644 --- a/module/programplan/test/programplan.class.php +++ b/module/programplan/test/programplan.class.php @@ -489,4 +489,21 @@ class programplanTest { return $this->objectModel->printCell($col, $plan, $users, $projectID); } + + /** + * 通过计算获取阶段状态。 + * Compute stage status. + * + * @param int $stage + * @param string $action + * @param bool $isParent + * @access public + * @return string + */ + public function computeProgressTest(int $stageID, string $action = '', bool $isParent = false): string + { + $result = $this->objectModel->computeProgress($stageID, $action, $isParent); + if(!$result) return 'fail'; + return 'success'; + } }