+ Add programplan-computerprogress test case.

This commit is contained in:
liuchenglong
2023-05-09 09:57:32 +00:00
parent 00b9ce900b
commit cbebcff10d
4 changed files with 96 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/programplan.class.php';
su('admin');
function initData()
{
zdTable('project')->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
@@ -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'
@@ -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"
@@ -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';
}
}