* Add unit test of execution.

This commit is contained in:
liumengyi
2022-08-26 14:51:49 +08:00
parent 754b84882e
commit cecf6460d7
4 changed files with 219 additions and 0 deletions
+105
View File
@@ -2081,4 +2081,109 @@ class executionTest
return $object;
}
}
/**
* Test get execution burn data.
*
* @param array $executionIDList
* @access public
* @return array
*/
public function getBurnDataTest($executionIDList)
{
global $tester;
$executions = $this->objectModel->getByIdList($executionIDList);
$objects = $this->objectModel->getBurnData($executions);
$returns = array();
foreach($objects as $executionID => $burnData)
{
$returns[$executionID] = '';
foreach($burnData as $data) $returns[$executionID] .= ",$data->value";
$returns[$executionID] = trim($returns[$executionID], ',');
}
if(dao::isError())
{
$error = dao::getError();
return $error;
}
else
{
return $returns;
}
}
/**
* Test get begin and end for CFD.
*
* @param int $executionID
* @access public
* @return array
*/
public function getBeginEnd4CFDTest($executionID)
{
global $tester;
$execution = $this->objectModel->getByID($executionID);
$object = $this->objectModel->getBeginEnd4CFD($execution);
$object[0] = $object[0] == date('Y-m-d', strtotime('-13 days', time())) ? 1 : 0;
$object[1] = $object[1] == helper::today() ? 1 : 0;
if(dao::isError())
{
$error = dao::getError();
return $error;
}
else
{
return $object;
}
}
/**
* Test get taskes by search.
*
* @param string $condition
* @param int $recPerPage
* @param string $orderBy
* @access public
* @return array
*/
public function getSearchTasksTest($condition, $recPerPage, $orderBy)
{
global $tester;
/* Load pager. */
$tester->app->loadClass('pager', $static = true);
$pager = new pager(0, $recPerPage, 1);
$objects = $this->objectModel->getSearchTasks($condition, $pager, $orderBy);
$returns = '';
foreach($objects as $object)
{
$returns .= "$object->id:name:$object->name";
if(!empty($object->team))
{
$returns .= ',team:[';
foreach($object->team as $team) $returns .= "$team->id,";
$returns = trim($returns, ',');
$returns .= ']';
}
$returns .= ';';
}
if(dao::isError())
{
$error = dao::getError();
return $error;
}
else
{
return $returns;
}
}
}
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
su('admin');
/**
title=executionModel->getBeginEnd4CFD();
cid=1
pid=1
ID 161 的专业研发看板累计流图默认开始和结束时间 是不是14天前和今天 >> 1,1
ID 162 的专业研发看板累计流图默认开始和结束时间 是不是14天前和今天 >> 1,1
ID 163 的专业研发看板累计流图默认开始和结束时间 是不是14天前和今天 >> 1,1
ID 171 的专业研发看板累计流图默认开始和结束时间 是不是14天前和今天 >> 1,1
ID 181 的专业研发看板累计流图默认开始和结束时间 是不是14天前和今天 >> 1,1
ID 191 的专业研发看板累计流图默认开始和结束时间 是不是14天前和今天 >> 1,1
*/
$executionIDList = array(161, 162, 163, 171, 181, 191);
$execution = new executionTest();
r($execution->getBeginEnd4CFDTest($executionIDList[0])) && p('0,1') && e('1,1'); // ID 161 的专业研发看板累计流图默认开始和结束时间 是不是14天前和今天
r($execution->getBeginEnd4CFDTest($executionIDList[1])) && p('0,1') && e('1,1'); // ID 162 的专业研发看板累计流图默认开始和结束时间 是不是14天前和今天
r($execution->getBeginEnd4CFDTest($executionIDList[2])) && p('0,1') && e('1,1'); // ID 163 的专业研发看板累计流图默认开始和结束时间 是不是14天前和今天
r($execution->getBeginEnd4CFDTest($executionIDList[3])) && p('0,1') && e('1,1'); // ID 171 的专业研发看板累计流图默认开始和结束时间 是不是14天前和今天
r($execution->getBeginEnd4CFDTest($executionIDList[4])) && p('0,1') && e('1,1'); // ID 181 的专业研发看板累计流图默认开始和结束时间 是不是14天前和今天
r($execution->getBeginEnd4CFDTest($executionIDList[5])) && p('0,1') && e('1,1'); // ID 191 的专业研发看板累计流图默认开始和结束时间 是不是14天前和今天
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
su('admin');
/**
title=executionModel->getBurnData();
cid=1
pid=1
测试获取 执行ID 101 102 的燃尽图 >> 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,36,36,36,36,36,36,36,36,36,36,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,4,null
测试获取 执行ID 101 103 111 的燃尽图 >> 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,36,36,36,36,36,36,36,36,36,36,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,23,23,23,23,23,23,23,23,23,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,27,27,27,27,27,27,27,27,27,null
测试获取 执行ID 111 121 131 的燃尽图 >> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,27,27,27,27,27,27,27,27,27,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,27,27,27,27,27,27,27,27,27,null;17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,null
测试获取 执行ID 101 102 103 111 121 131 的燃尽图 >> 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,36,36,36,36,36,36,36,36,36,36,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,4,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,23,23,23,23,23,23,23,23,23,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,27,27,27,27,27,27,27,27,27,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,27,27,27,27,27,27,27,27,27,null;17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,null
*/
$executionIDList = array(array(101, 102), array(101, 103, 111), array(111, 121, 131), array(101, 102, 103, 111, 121, 131));
$execution = new executionTest();
r($execution->getBurnDataTest($executionIDList[0])) && p('101;102') && e('21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,36,36,36,36,36,36,36,36,36,36,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,4,null'); // 测试获取 执行ID 101 102 的燃尽图
r($execution->getBurnDataTest($executionIDList[1])) && p('101;103;111') && e('21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,36,36,36,36,36,36,36,36,36,36,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,23,23,23,23,23,23,23,23,23,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,27,27,27,27,27,27,27,27,27,null'); // 测试获取 执行ID 101 103 111 的燃尽图
r($execution->getBurnDataTest($executionIDList[2])) && p('111;121;131') && e('0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,27,27,27,27,27,27,27,27,27,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,27,27,27,27,27,27,27,27,27,null;17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,null'); // 测试获取 执行ID 111 121 131 的燃尽图
r($execution->getBurnDataTest($executionIDList[3])) && p('101;102;103;111;121;131') && e('21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,36,36,36,36,36,36,36,36,36,36,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,4,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,23,23,23,23,23,23,23,23,23,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,27,27,27,27,27,27,27,27,27,null;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,27,27,27,27,27,27,27,27,27,null;17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,null'); // 测试获取 执行ID 101 102 103 111 121 131 的燃尽图
+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';
su('admin');
/**
title=executionModel->getSearchTasks();
cid=1
pid=1
测试通过sql语句获取3个任务 id 倒序 execution = '101' and deleted = '0' and parent >= 0 >> 910:name:子任务10;909:name:子任务9,team:[930,920];908:name:子任务8,team:[919,929];
测试通过sql语句获取3个任务 id 正序 execution = '101' and deleted = '0' and parent >= 0 >> 1:name:开发任务11,team:[911,921];901:name:子任务1,team:[922,912];902:name:子任务2,team:[923,913];
测试通过sql语句获取5个任务 id 倒序 execution = '101' and deleted = '0' and parent >= 0 >> 910:name:子任务10;909:name:子任务9,team:[930,920];908:name:子任务8,team:[919,929];907:name:子任务7,team:[918,928];906:name:子任务6,team:[927,917];
测试通过sql语句获取5个任务 id 正序 execution = '101' and deleted = '0' and parent >= 0 >> 1:name:开发任务11,team:[911,921];901:name:子任务1,team:[922,912];902:name:子任务2,team:[923,913];903:name:子任务3,team:[914,924];904:name:子任务4,team:[915,925];
测试通过sql语句获取3个任务 id 倒序 type = 'devel' and fromBug != '0' and parent >= 0 >> 0
测试通过sql语句获取3个任务 id 正序 type = 'devel' and fromBug != '0' and parent >= 0 >> 0
测试通过sql语句获取5个任务 id 倒序 type = 'devel' and fromBug != '0' and parent >= 0 >> 0
测试通过sql语句获取5个任务 id 正序 type = 'devel' and fromBug != '0' and parent >= 0 >> 0
测试通过sql语句获取3个任务 id 倒序 execution = '101' and story != '0' and parent >= 0 >> 1:name:开发任务11,team:[911,921];
测试通过sql语句获取3个任务 id 正序 execution = '101' and story != '0' and parent >= 0 >> 1:name:开发任务11,team:[911,921];
测试通过sql语句获取5个任务 id 倒序 execution = '101' and story != '0' and parent >= 0 >> 1:name:开发任务11,team:[911,921];
测试通过sql语句获取5个任务 id 正序 execution = '101' and story != '0' and parent >= 0 >> 1:name:开发任务11,team:[911,921];
测试通过sql语句获取3个任务 id 倒序 module like '%2%' and type = 'design' and parent >= 0 >> 909:name:子任务9,team:[930,920];901:name:子任务1,team:[922,912];801:name:更多任务201;
测试通过sql语句获取3个任务 id 正序 module like '%2%' and type = 'design' and parent >= 0 >> 1:name:开发任务11,team:[911,921];65:name:开发任务75;73:name:开发任务83;
测试通过sql语句获取5个任务 id 倒序 module like '%2%' and type = 'design' and parent >= 0 >> 909:name:子任务9,team:[930,920];901:name:子任务1,team:[922,912];801:name:更多任务201;769:name:更多任务169;737:name:更多任务137;
测试通过sql语句获取5个任务 id 正序 module like '%2%' and type = 'design' and parent >= 0 >> 1:name:开发任务11,team:[911,921];65:name:开发任务75;73:name:开发任务83;81:name:开发任务91;89:name:开发任务99;
*/
$condition = array();
$condition[] = "execution = '101' and deleted = '0' and parent >= 0";
$condition[] = "type = 'devel' and fromBug != '0' and parent >= 0";
$condition[] = "execution = '101' and story != '0' and parent >= 0";
$condition[] = "module like '%2%' and type = 'design' and parent >= 0";
$recPerPage = array('3', '5');
$orderBy = array('id_desc', 'id_asc');
$execution = new executionTest();
r($execution->getSearchTasksTest($condition[0], $recPerPage[0], $orderBy[0])) && p() && e('910:name:子任务10;909:name:子任务9,team:[930,920];908:name:子任务8,team:[919,929];'); // 测试通过sql语句获取3个任务 id 倒序 execution = '101' and deleted = '0' and parent >= 0
r($execution->getSearchTasksTest($condition[0], $recPerPage[0], $orderBy[1])) && p() && e('1:name:开发任务11,team:[911,921];901:name:子任务1,team:[922,912];902:name:子任务2,team:[923,913];'); // 测试通过sql语句获取3个任务 id 正序 execution = '101' and deleted = '0' and parent >= 0
r($execution->getSearchTasksTest($condition[0], $recPerPage[1], $orderBy[0])) && p() && e('910:name:子任务10;909:name:子任务9,team:[930,920];908:name:子任务8,team:[919,929];907:name:子任务7,team:[918,928];906:name:子任务6,team:[927,917];'); // 测试通过sql语句获取5个任务 id 倒序 execution = '101' and deleted = '0' and parent >= 0
r($execution->getSearchTasksTest($condition[0], $recPerPage[1], $orderBy[1])) && p() && e('1:name:开发任务11,team:[911,921];901:name:子任务1,team:[922,912];902:name:子任务2,team:[923,913];903:name:子任务3,team:[914,924];904:name:子任务4,team:[915,925];'); // 测试通过sql语句获取5个任务 id 正序 execution = '101' and deleted = '0' and parent >= 0
r($execution->getSearchTasksTest($condition[1], $recPerPage[0], $orderBy[0])) && p() && e('0'); // 测试通过sql语句获取3个任务 id 倒序 type = 'devel' and fromBug != '0' and parent >= 0
r($execution->getSearchTasksTest($condition[1], $recPerPage[0], $orderBy[1])) && p() && e('0'); // 测试通过sql语句获取3个任务 id 正序 type = 'devel' and fromBug != '0' and parent >= 0
r($execution->getSearchTasksTest($condition[1], $recPerPage[1], $orderBy[0])) && p() && e('0'); // 测试通过sql语句获取5个任务 id 倒序 type = 'devel' and fromBug != '0' and parent >= 0
r($execution->getSearchTasksTest($condition[1], $recPerPage[1], $orderBy[1])) && p() && e('0'); // 测试通过sql语句获取5个任务 id 正序 type = 'devel' and fromBug != '0' and parent >= 0
r($execution->getSearchTasksTest($condition[2], $recPerPage[0], $orderBy[0])) && p() && e('1:name:开发任务11,team:[911,921];'); // 测试通过sql语句获取3个任务 id 倒序 execution = '101' and story != '0' and parent >= 0
r($execution->getSearchTasksTest($condition[2], $recPerPage[0], $orderBy[1])) && p() && e('1:name:开发任务11,team:[911,921];'); // 测试通过sql语句获取3个任务 id 正序 execution = '101' and story != '0' and parent >= 0
r($execution->getSearchTasksTest($condition[2], $recPerPage[1], $orderBy[0])) && p() && e('1:name:开发任务11,team:[911,921];'); // 测试通过sql语句获取5个任务 id 倒序 execution = '101' and story != '0' and parent >= 0
r($execution->getSearchTasksTest($condition[2], $recPerPage[1], $orderBy[1])) && p() && e('1:name:开发任务11,team:[911,921];'); // 测试通过sql语句获取5个任务 id 正序 execution = '101' and story != '0' and parent >= 0
r($execution->getSearchTasksTest($condition[3], $recPerPage[0], $orderBy[0])) && p() && e('909:name:子任务9,team:[930,920];901:name:子任务1,team:[922,912];801:name:更多任务201;'); // 测试通过sql语句获取3个任务 id 倒序 module like '%2%' and type = 'design' and parent >= 0
r($execution->getSearchTasksTest($condition[3], $recPerPage[0], $orderBy[1])) && p() && e('1:name:开发任务11,team:[911,921];65:name:开发任务75;73:name:开发任务83;'); // 测试通过sql语句获取3个任务 id 正序 module like '%2%' and type = 'design' and parent >= 0
r($execution->getSearchTasksTest($condition[3], $recPerPage[1], $orderBy[0])) && p() && e('909:name:子任务9,team:[930,920];901:name:子任务1,team:[922,912];801:name:更多任务201;769:name:更多任务169;737:name:更多任务137;'); // 测试通过sql语句获取5个任务 id 倒序 module like '%2%' and type = 'design' and parent >= 0
r($execution->getSearchTasksTest($condition[3], $recPerPage[1], $orderBy[1])) && p() && e('1:name:开发任务11,team:[911,921];65:name:开发任务75;73:name:开发任务83;81:name:开发任务91;89:name:开发任务99;'); // 测试通过sql语句获取5个任务 id 正序 module like '%2%' and type = 'design' and parent >= 0