* Add test case and remove unused function.
This commit is contained in:
@@ -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']);
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -2708,7 +2708,7 @@ class executionTest
|
||||
* @param int $executionID
|
||||
* @param int $queryID
|
||||
* @access public
|
||||
* @return void
|
||||
* @return int
|
||||
*/
|
||||
public function buildTaskSearchFormTest($executionID, $queryID)
|
||||
{
|
||||
@@ -2723,7 +2723,7 @@ class executionTest
|
||||
* @param int $productID
|
||||
* @param int $queryID
|
||||
* @access public
|
||||
* @return void
|
||||
* @return int
|
||||
*/
|
||||
public function buildBugSearchFormTest($productID, $queryID)
|
||||
{
|
||||
@@ -2742,7 +2742,7 @@ class executionTest
|
||||
* @param int $executionID
|
||||
* @param int $queryID
|
||||
* @access public
|
||||
* @return void
|
||||
* @return int
|
||||
*/
|
||||
public function buildStorySearchFormTest($executionID, $queryID)
|
||||
{
|
||||
@@ -2756,4 +2756,40 @@ 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');
|
||||
}
|
||||
}
|
||||
|
||||
59
test/model/execution/buildcfddata.php
Normal file
59
test/model/execution/buildcfddata.php
Normal 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'); // 存在的执行的累计流图信息
|
||||
@@ -42,7 +42,7 @@ cid=1
|
||||
pid=1
|
||||
|
||||
获取所有看板执行的累计卡片个数 >> 6
|
||||
获取看板1的累计流图信息 >> 3,task
|
||||
获取看板1的累计流图信息 >> 3,task
|
||||
|
||||
*/
|
||||
|
||||
|
||||
57
test/model/execution/getcfddata.php
Normal file
57
test/model/execution/getcfddata.php
Normal 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'); // 存在的执行的累计流图信息
|
||||
Reference in New Issue
Block a user