* Modify checkTopstage function test case for programplan model.

This commit is contained in:
jukui
2023-05-09 13:08:15 +08:00
parent af0e8504dc
commit 4b36888f19
4 changed files with 36 additions and 23 deletions
+5 -2
View File
@@ -197,7 +197,7 @@ class programplanModel extends model
}
$datas = $this->setRelationTask($planIdList, $datas);
$datas['data'] = isset($datas['data']) ? array_values($datas['data']) : array();
return $returnJson ? json_encode($datas) : $datas;
}
@@ -1070,6 +1070,8 @@ class programplanModel extends model
common::printIcon('execution', 'delete', "planID=$plan->id&confirm=no", $plan, 'list', 'trash', 'hiddenwin' , $disabled, '', '', $this->lang->programplan->delete);
}
break;
default:
break;
}
echo '</td>';
}
@@ -1363,13 +1365,14 @@ class programplanModel extends model
}
/**
* 检查是否为顶级。
* Check whether it is the top stage.
*
* @param int $planID
* @access public
* @return bool
*/
public function checkTopStage($planID)
public function checkTopStage(int $planID): bool
{
$parentID = $this->dao->select('parent')->from(TABLE_EXECUTION)->where('id')->eq($planID)->fetch('parent');
$parentType = $this->dao->select('type')->from(TABLE_EXECUTION)->where('id')->eq($parentID)->fetch('type');
@@ -2,22 +2,11 @@
<?php
include dirname(__FILE__, 5) . "/test/lib/init.php";
include dirname(__FILE__, 2) . '/programplan.class.php';
zdTable('user')->gen(5);
su('admin');
$execution = zdTable('project');
$execution->id->range('1-5');
$execution->name->range('瀑布项目1,阶段a,阶段a子1,阶段a子1子1,阶段b');
$execution->type->range('project,stage{4}');
$execution->project->range('0,1{4}');
$execution->parent->range('0,1,2,3,1');
$execution->path->range("`,1,`,`,1,2,`,`,1,2,3,`,`,1,2,3,4,`,`,1,5,`");
$execution->status->range('doing,doing,doing,closed,suspended');
$execution->openedBy->range('admin,user1');
$execution->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD');
$execution->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD');
$execution->realBegan->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD');
$execution->gen(5);
zdTable('project')->config('checktopstage')->gen(5);
/**
@@ -25,14 +14,10 @@ title=测试programplanModel->checkTopStage();
cid=1
pid=1
测试id为2判断是否为顶级阶段 >> 1
测试id为4判断是否为顶级阶段 >> 0
测试id为5判断是否为顶级阶段 >> 1
*/
$plan = new programplanTest();
r($plan->checkTopStageTest(2)) && p('') && e(1); // 测试id为2判断是否为顶级阶段
r($plan->checkTopStageTest(4)) && p('') && e(0); // 测试id为4判断是否为顶级阶段
r($plan->checkTopStageTest(5)) && p('') && e(1); // 测试id为5判断是否为顶级阶段
r($plan->checkTopStageTest(2)) && p('') && e('1'); // 测试id为2判断是否为顶级阶段
r($plan->checkTopStageTest(4)) && p('') && e('0'); // 测试id为4判断是否为顶级阶段
r($plan->checkTopStageTest(5)) && p('') && e('1'); // 测试id为5判断是否为顶级阶段
@@ -0,0 +1,25 @@
title: checktopstage
author: jukui
version: '1.0'
fields:
- field: id
range: 1-5
- field: project
range: 1-5
- field: name
range: '瀑布项目1,阶段a,阶段a子1,阶段a子1子1,阶段b'
- field: parent
range: '0,1,2,3,1'
- field: type
range: 'project,stage{4}'
- field: grade
range: 1
- field: days
range: 1
- field: status
range: 'doing,doing,doing,closed,suspended'
- field: desc
range: 1-5
prefix: '项目描述'
- field: path
range: "`,1,`,`,1,2,`,`,1,2,3,`,`,1,2,3,4,`,`,1,5,`"