Merge branch 'sprint/tsj_uinttest' into 'master'

* Add test case and remove unused function.

See merge request easycorp/zentaopms!6788
This commit is contained in:
王怡栋
2023-01-29 06:37:57 +00:00
8 changed files with 311 additions and 44 deletions
-2
View File
@@ -1531,8 +1531,6 @@ class execution extends control
}
$dateList = date::getDateList($begin, $end, 'Y-m-d', $withWeekend == 'false'? 'noweekend' : '');
//list($cycleTimeAvg, $throughput) = $this->execution->getCFDStatistics($executionID, $dateList, $type);
$chartData = $this->execution->buildCFDData($executionID, $dateList, $type);
if(isset($chartData['line'])) $chartData['line'] = array_reverse($chartData['line']);
-38
View File
@@ -3763,44 +3763,6 @@ class executionModel extends model
return $data;
}
/**
* Get CFD statistics.
*
* @param int $executionID
* @param array $dateList
* @param string $type
* @access public
* @return void
*/
public function getCFDStatistics($executionID, $dateList, $type)
{
$kanbanData = $this->loadModel('kanban')->getRDKanban($executionID, $type);
$kanbanData = array_shift($kanbanData);
$cycleTime = array();
foreach($kanbanData->groups as $group)
{
foreach($group->lanes as $lane)
{
if(!isset($lane->items['closed'])) continue;
foreach($lane->items['closed'] as $item)
{
$diffTime = $type == 'story' ? strtotime($item['lastEditedDate']) - strtotime($item['openedDate']) : strtotime($item['closedDate']) - strtotime($item['openedDate']);
$day = round($diffTime / (3600 * 24), 1);
if($day > 0) $cycleTime[$item['id']] = $day;
}
}
}
$itemCount = count($cycleTime);
if(!$itemCount) return array('', '');
$cycleTimeAvg = round(array_sum($cycleTime) / $itemCount, 1);
$throughput = round(($itemCount * 7) / $cycleTimeAvg, 1) . "{$this->lang->execution->kanbanCardsUnit}/" . $this->lang->execution->week;
return array($cycleTimeAvg, $throughput);
}
/**
* Get taskes by search.
*
+81 -3
View File
@@ -1809,6 +1809,31 @@ class executionTest
}
}
/**
* Function getBurnData test by execution.
*
* @param int $executionID
* @access public
* @return int
*/
public function getBurnDataTest($executionID = 0)
{
$execution = $this->executionModel->getByID($executionID);
if(empty($execution)) return '0';
$object = $this->executionModel->getBurnData(array($executionID => $execution));
if(dao::isError())
{
$error = dao::getError();
return $error;
}
else
{
return $object;
}
}
/**
* function processBurnData test by execution
*
@@ -2708,7 +2733,7 @@ class executionTest
* @param int $executionID
* @param int $queryID
* @access public
* @return void
* @return int
*/
public function buildTaskSearchFormTest($executionID, $queryID)
{
@@ -2723,7 +2748,7 @@ class executionTest
* @param int $productID
* @param int $queryID
* @access public
* @return void
* @return int
*/
public function buildBugSearchFormTest($productID, $queryID)
{
@@ -2742,7 +2767,7 @@ class executionTest
* @param int $executionID
* @param int $queryID
* @access public
* @return void
* @return int
*/
public function buildStorySearchFormTest($executionID, $queryID)
{
@@ -2756,4 +2781,57 @@ class executionTest
return $_SESSION['executionStorysearchParams']['queryID'];
}
/**
* Test get CFD data.
*
* @param int $executionID
* @access public
* @return array
*/
public function getCFDDataTest($executionID = 0)
{
$begin = strtotime('2022-01-12');
$end = strtotime('2022-02-12');
$dateList = array();
for($date = $begin; $date <= $end; $date += 24 * 3600) $dateList[] = date('Y-m-d', $date);
return $this->executionModel->getCFDData($executionID, $dateList);
}
/**
* Test build CFD data.
*
* @param int $executionID
* @access public
* @return array
*/
public function buildCFDDataTest($executionID = 0)
{
$begin = strtotime('2022-01-12');
$end = strtotime('2022-02-12');
$dateList = array();
for($date = $begin; $date <= $end; $date += 24 * 3600) $dateList[] = date('Y-m-d', $date);
return $this->executionModel->buildCFDData($executionID, $dateList, 'task');
}
/**
* Test check CFD data.
*
* @param int $executionID
* @param string $date
* @access public
* @return array
*/
public function checkCFDDataTest($executionID, $date)
{
$this->executionModel->checkCFDData($executionID, $date);
return $this->executionModel->dao->select("date, `count` AS value, `name`")->from(TABLE_CFD)
->where('execution')->eq((int)$executionID)
->andWhere('date')->eq($date)
->orderBy('date DESC, id asc')->fetchGroup('name', 'date');
}
}
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
zdTable('user')->gen(5);
su('admin');
$execution = zdTable('project');
$execution->id->range('1-5');
$execution->name->range('项目集1,项目1,看板1,看板2,看板3');
$execution->type->range('program,project,,kanban{3}');
$execution->parent->range('0,1,2{3}');
$execution->status->range('wait{3},closed,doing');
$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->gen(5);
$kanbanCell = zdTable('kanbancell');
$kanbanCell->id->range('1-9');
$kanbanCell->kanban->range('3{3},4{3},5{3}');
$kanbanCell->lane->range('1-9');
$kanbanCell->column->range('1-9');
$kanbanCell->type->range('task,bug,story');
$kanbanCell->cards->range('`,1,2,3,`{3},`,4,5,`{3},6{3}');
$kanbanCell->gen(9);
$kanbanColumn = zdTable('kanbancolumn');
$kanbanColumn->id->range('1-9');
$kanbanColumn->name->range('1-9')->prefix('看板列');
$kanbanColumn->type->range('1-9')->prefix('column');
$kanbanColumn->gen(9);
$CFD = zdTable('cfd');
$CFD->id->range('1-5');
$CFD->execution->range('3');
$CFD->count->range('1');
$CFD->type->range('task,bug,story');
$CFD->date->range('20220122 000000:0')->type('timestamp')->format('YY/MM/DD');
$CFD->name->range('1-5')->prefix('看板列');
$CFD->gen(5);
/**
title=测试executionModel->buildCFDData();
cid=1
pid=1
不存在执行的累计流图信息 >> 0
存在的执行的累计流图信息 >> 2
*/
$executionTester = new executionTest();
r(count($executionTester->buildCFDDataTest())) && p() && e('0'); // 不存在执行的累计流图信息
$CFDData = $executionTester->buildCFDDataTest(3);
r(count($CFDData['line'])) && p() && e('2'); // 存在的执行的累计流图信息
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
zdTable('user')->gen(5);
su('admin');
$execution = zdTable('project');
$execution->id->range('1-5');
$execution->name->range('项目集1,项目1,看板1,看板2,看板3');
$execution->type->range('program,project,,kanban{3}');
$execution->parent->range('0,1,2{3}');
$execution->status->range('wait{3},closed,doing');
$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->gen(5);
$kanbanCell = zdTable('kanbancell');
$kanbanCell->id->range('1-9');
$kanbanCell->kanban->range('3{3},4{3},5{3}');
$kanbanCell->lane->range('1-9');
$kanbanCell->column->range('1-9');
$kanbanCell->type->range('task,bug,story');
$kanbanCell->cards->range('`,1,2,3,`{3},`,4,5,`{3},6{3}');
$kanbanCell->gen(9);
$kanbanColumn = zdTable('kanbancolumn');
$kanbanColumn->id->range('1-9');
$kanbanColumn->name->range('1-9')->prefix('看板列');
$kanbanColumn->type->range('1-9')->prefix('column');
$kanbanColumn->gen(9);
$CFD = zdTable('cfd');
$CFD->id->range('1-5');
$CFD->execution->range('3');
$CFD->count->range('1');
$CFD->type->range('task,bug,story');
$CFD->date->range('20220122 000000:0')->type('timestamp')->format('YY/MM/DD');
$CFD->name->range('1-5')->prefix('看板列');
$CFD->gen(5);
/**
title=测试executionModel->checkCFDData();
cid=1
pid=1
已有日期的情况 >> 5
未来日期的情况 >> 0
*/
$executionTester = new executionTest();
$dateList = array('2022-01-22', '2099-01-01');
r(count($executionTester->checkCFDDataTest(3, $dateList[0]))) && p() && e('5'); // 已有日期的情况
r(count($executionTester->checkCFDDataTest(3, $dateList[1]))) && p() && e('0'); // 未来日期的情况
+1 -1
View File
@@ -42,7 +42,7 @@ cid=1
pid=1
获取所有看板执行的累计卡片个数 >> 6
获取看板1的累计流图信息 >> 3,task
获取看板1的累计流图信息 >> 3,task
*/
+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
zdTable('user')->gen(5);
su('admin');
$execution = zdTable('project');
$execution->id->range('1-5');
$execution->name->range('项目集1,项目1,迭代1,阶段1,看板1');
$execution->type->range('program,project,sprint,stage,kanban');
$execution->code->range('1-5')->prefix('code');
$execution->parent->range('0,1,2{3}');
$execution->status->range('wait{3},suspended,closed,doing');
$execution->openedBy->range('admin,user1');
$execution->begin->range('20220110 000000:0')->type('timestamp')->format('YY/MM/DD');
$execution->end->range('20220220 000000:0')->type('timestamp')->format('YY/MM/DD');
$execution->gen(5);
$burn = zdTable('burn');
$burn->execution->range('3{5},4{5},5{5}');
$burn->date->range('20220111 000000:1D')->type('timestamp')->format('YY/MM/DD');
$burn->estimate->range('94.3,56.3,55.3,37.8,33.8');
$burn->left->range('95.3,68.5,73.9,40.2,36,3');
$burn->consumed->range('20.1,33.4,41,56.55,59.55');
$burn->storyPoint->range('0,16.5,16,11.5,9');
$burn->gen(15);
$task = zdTable('task');
$task->id->range('1-10');
$task->execution->range('3');
$task->status->range('wait,doing');
$task->estimate->range('1-10');
$task->left->range('1-10');
$task->consumed->range('1-10');
$task->gen(10);
/**
title=测试executionModel->getBurnDataTest();
cid=1
pid=1
敏捷执行查询统计 >> 36
瀑布执行查询统计 >> 40.2
看板执行查询统计 >> 3
*/
$executionIDList = array(3, 4, 5);
$execution = new executionTest();
r(current($execution->getBurnDataTest($executionIDList[0]))) && p('2022-01-22:value') && e('36'); // 敏捷执行查询统计
r(current($execution->getBurnDataTest($executionIDList[1]))) && p('2022-01-22:value') && e('40.2'); // 瀑布执行查询统计
r(current($execution->getBurnDataTest($executionIDList[2]))) && p('2022-01-22:value') && e('3'); // 看板执行查询统计
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
zdTable('user')->gen(5);
su('admin');
$execution = zdTable('project');
$execution->id->range('1-5');
$execution->name->range('项目集1,项目1,看板1,看板2,看板3');
$execution->type->range('program,project,,kanban{3}');
$execution->parent->range('0,1,2{3}');
$execution->status->range('wait{3},closed,doing');
$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->gen(5);
$kanbanCell = zdTable('kanbancell');
$kanbanCell->id->range('1-9');
$kanbanCell->kanban->range('3{3},4{3},5{3}');
$kanbanCell->lane->range('1-9');
$kanbanCell->column->range('1-9');
$kanbanCell->type->range('task,bug,story');
$kanbanCell->cards->range('`,1,2,3,`{3},`,4,5,`{3},6{3}');
$kanbanCell->gen(9);
$kanbanColumn = zdTable('kanbancolumn');
$kanbanColumn->id->range('1-9');
$kanbanColumn->name->range('1-9')->prefix('看板列');
$kanbanColumn->type->range('1-9')->prefix('column');
$kanbanColumn->gen(9);
$CFD = zdTable('cfd');
$CFD->id->range('1-5');
$CFD->execution->range('3');
$CFD->count->range('1');
$CFD->type->range('task,bug,story');
$CFD->date->range('20220122 000000:0')->type('timestamp')->format('YY/MM/DD');
$CFD->name->range('1-5')->prefix('看板列');
$CFD->gen(5);
/**
title=测试executionModel->getCFDData();
cid=1
pid=1
不存在执行的累计流图信息 >> 0
存在的执行的累计流图信息 >> 看板列3
*/
$executionTester = new executionTest();
r(count($executionTester->getCFDDataTest())) && p() && e('0'); // 不存在执行的累计流图信息
r(current($executionTester->getCFDDataTest(3))) && p('2022-01-22:name') && e('看板列3'); // 存在的执行的累计流图信息