* Refactor holidayModel::updateProgramPlanDuration, and modify its unit test.
This commit is contained in:
@@ -293,14 +293,15 @@ class holidayModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Update project plan duration.
|
||||
* 更新项目的工期。
|
||||
* Update project duration.
|
||||
*
|
||||
* @param string $beginDate
|
||||
* @param string $endDate
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function updateProgramPlanDuration($beginDate, $endDate)
|
||||
public function updateProgramPlanDuration(string $beginDate, string $endDate): void
|
||||
{
|
||||
$updateProjectList = $this->dao->select('id, begin, end')
|
||||
->from(TABLE_PROJECT)
|
||||
@@ -309,7 +310,7 @@ class holidayModel extends model
|
||||
->andWhere('end')->ne(LONG_TIME)
|
||||
->andWhere('begin', true)->between($beginDate, $endDate)
|
||||
->orWhere('end')->between($beginDate, $endDate)
|
||||
->orWhere("(begin < '$beginDate' AND end > '$endDate')")
|
||||
->orWhere("(begin < '{$beginDate}' AND end > '{$endDate}')")
|
||||
->markRight(1)
|
||||
->fetchAll();
|
||||
|
||||
|
||||
@@ -251,20 +251,23 @@ class holidayTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Test updateProgramPlanDuration method.
|
||||
* 测试更新项目工期。
|
||||
* Test update project duration.
|
||||
*
|
||||
* @param int $testProjectID
|
||||
* @param object $holiday
|
||||
* @param int $holidayID
|
||||
* @access public
|
||||
* @return int
|
||||
* @return int|array
|
||||
*/
|
||||
public function updateProgramPlanDurationTest($testProjectID, $holidayID)
|
||||
public function updateProgramPlanDurationTest(int $testProjectID, int $holidayID, bool $updateDuration): int|array
|
||||
{
|
||||
global $tester;
|
||||
|
||||
$holiday = $tester->dao->select('*')->from(TABLE_HOLIDAY)->where('id')->eq($holidayID)->fetch();
|
||||
|
||||
$this->objectModel->updateProgramPlanDuration($holiday->begin, $holiday->end);
|
||||
if($updateDuration)
|
||||
{
|
||||
$holiday = $tester->dao->select('*')->from(TABLE_HOLIDAY)->where('id')->eq($holidayID)->fetch();
|
||||
$this->objectModel->updateProgramPlanDuration($holiday->begin, $holiday->end);
|
||||
}
|
||||
|
||||
$project = $tester->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($testProjectID)->fetch();
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/holiday.class.php';
|
||||
|
||||
zdTable('holiday')->gen(10);
|
||||
zdTable('project')->config('execution')->gen(5);
|
||||
zdTable('user')->gen(1);
|
||||
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
@@ -10,30 +16,21 @@ title=测试 holidayModel->updateProgramPlanDuration();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试插入id为1的节假日时迭代101项目的planDuration >> 59
|
||||
测试插入id为3的节假日时迭代101项目的planDuration >> 59
|
||||
测试插入id为1的节假日时迭代102项目的planDuration >> 58
|
||||
测试插入id为3的节假日时迭代102项目的planDuration >> 58
|
||||
测试插入id为1的节假日时迭代750项目的planDuration >> 58
|
||||
测试插入id为3的节假日时迭代750项目的planDuration >> 58
|
||||
测试插入id为1的节假日时迭代1项目的planDuration >> 59
|
||||
测试插入id为3的节假日时迭代1项目的planDuration >> 59
|
||||
测试插入id为1的节假日时迭代11项目的planDuration >> 59
|
||||
测试插入id为3的节假日时迭代11项目的planDuration >> 59
|
||||
|
||||
*/
|
||||
$holidayIDList = array('1', '3', '99', '100');
|
||||
$holidayIdList = array(10, 5, 1);
|
||||
$projectIdList = array(11, 61, 101);
|
||||
$updateDuration = array(true, false);
|
||||
|
||||
$holiday = new holidayTest();
|
||||
|
||||
r($holiday->updateProgramPlanDurationTest(101, $holidayIDList[0])) && p() && e('59'); //测试插入id为1的节假日时迭代101项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest(101, $holidayIDList[1])) && p() && e('59'); //测试插入id为3的节假日时迭代101项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest(102, $holidayIDList[0])) && p() && e('58'); //测试插入id为1的节假日时迭代102项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest(102, $holidayIDList[1])) && p() && e('58'); //测试插入id为3的节假日时迭代102项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest(750, $holidayIDList[0])) && p() && e('58'); //测试插入id为1的节假日时迭代750项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest(750, $holidayIDList[1])) && p() && e('58'); //测试插入id为3的节假日时迭代750项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest(1, $holidayIDList[0])) && p() && e('59'); //测试插入id为1的节假日时迭代1项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest(1, $holidayIDList[1])) && p() && e('59'); //测试插入id为3的节假日时迭代1项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest(11, $holidayIDList[0])) && p() && e('59'); //测试插入id为1的节假日时迭代11项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest(11, $holidayIDList[1])) && p() && e('59'); //测试插入id为3的节假日时迭代11项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest($projectIdList[0], $holidayIdList[0], $updateDuration[0])) && p() && e('58'); //测试插入id为 10 的节假日时迭代 11 项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest($projectIdList[1], $holidayIdList[0], $updateDuration[1])) && p() && e('58'); //测试插入id为 10 的节假日时迭代 60 项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest($projectIdList[2], $holidayIdList[0], $updateDuration[1])) && p() && e('59'); //测试插入id为 10 的节假日时迭代 101 项目的planDuration
|
||||
|
||||
r($holiday->updateProgramPlanDurationTest($projectIdList[0], $holidayIdList[1], $updateDuration[0])) && p() && e('58'); //测试插入id为 5 的节假日时迭代 11 项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest($projectIdList[1], $holidayIdList[1], $updateDuration[1])) && p() && e('58'); //测试插入id为 5 的节假日时迭代 60 项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest($projectIdList[2], $holidayIdList[1], $updateDuration[1])) && p() && e('59'); //测试插入id为 5 的节假日时迭代 101 项目的planDuration
|
||||
|
||||
r($holiday->updateProgramPlanDurationTest($projectIdList[0], $holidayIdList[2], $updateDuration[0])) && p() && e('58'); //测试插入id为 5 的节假日时迭代 11 项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest($projectIdList[1], $holidayIdList[2], $updateDuration[1])) && p() && e('58'); //测试插入id为 5 的节假日时迭代 60 项目的planDuration
|
||||
r($holiday->updateProgramPlanDurationTest($projectIdList[2], $holidayIdList[2], $updateDuration[1])) && p() && e('59'); //测试插入id为 5 的节假日时迭代 101 项目的planDuration
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
title: execution.
|
||||
desc: execution data.
|
||||
author: Wang Yidong
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 11,60,61,100,101-700
|
||||
- field: name
|
||||
note: "名称"
|
||||
fields:
|
||||
- field: name1
|
||||
range: 敏捷项目,瀑布项目{2},看板项目,迭代{5},阶段{18},看板{5}
|
||||
- field: name2
|
||||
range: 1-10000
|
||||
- field: project
|
||||
range: 0{4},11{5},60{12},61{6},100{5}
|
||||
- field: model
|
||||
range: scrum,waterfall{2},kanban,[]{28}
|
||||
- field: attribute
|
||||
range: "[]{4},[]{5},request,design,dev,qa,release,review,request,design,dev,qa,release,review,request,design,dev,qa,release,review,[]{5}"
|
||||
- field: type
|
||||
range: project{4},sprint{5},stage{18},kanban{5}
|
||||
- field: budget
|
||||
range: 800000-1:100
|
||||
- field: status
|
||||
range: doing{4},wait{2},doing{2},suspended{2},closed{2}
|
||||
- field: auth
|
||||
range: "extend"
|
||||
- field: desc
|
||||
range: 1-10000
|
||||
prefix: "迭代描述"
|
||||
- field: begin
|
||||
range: "(-2M)-(+M):1D"
|
||||
type: timestamp
|
||||
format: "YY/MM/DD"
|
||||
postfix: "\t"
|
||||
- field: end
|
||||
range: "(+1w)-(+2M):1D"
|
||||
type: timestamp
|
||||
format: "YY/MM/DD"
|
||||
postfix: "\t"
|
||||
- field: grade
|
||||
range: 1{4},1{5},1{6},2{6},1{6},1{5}
|
||||
- field: parent
|
||||
range: 0{4},11{5},60{6},106-111,61{6},100{5}
|
||||
- field: path
|
||||
fields:
|
||||
- field: path1
|
||||
prefix: ","
|
||||
range: 11,60,61,100,11{5},60{12},61{6},100{5}
|
||||
- field: path2
|
||||
prefix: ","
|
||||
range: "[]{4},101-105,106-111,106-111,118-700"
|
||||
postfix: ","
|
||||
- field: path3
|
||||
range: "[]{4},[]{5},[]{6},112-117,[]{50}"
|
||||
postfix: ","
|
||||
- field: acl
|
||||
range: open{4},private{4}
|
||||
- field: multiple
|
||||
range: 1{4},1{3},0{2},1{18},1{5}
|
||||
- field: deleted
|
||||
range: 0{30},1
|
||||
Reference in New Issue
Block a user