* Refactor test case of getListByStory method.
This commit is contained in:
@@ -4,20 +4,71 @@ include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/task.class.php';
|
||||
su('admin');
|
||||
|
||||
zdTable('task')->config('task')->gen(12);
|
||||
|
||||
/**
|
||||
|
||||
title=taskModel->getListByStory();
|
||||
timeout=0
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
根据需求查看任务 >> 开发任务11
|
||||
根据需求查看任务数量统计 >> 6
|
||||
|
||||
*/
|
||||
|
||||
$storyID = '1';
|
||||
$count = array('0','1');
|
||||
$storyIdList = array(0, 1, 2, 3);
|
||||
$executionIdList = array(3, 4, 6);
|
||||
$projectIdList = array(1, 2);
|
||||
|
||||
$task = new taskTest();
|
||||
r($task->getListByStoryTest($storyID,$count[0])) && p('1:name') && e('开发任务11'); // 根据需求查看任务
|
||||
r($task->getListByStoryTest($storyID,$count[1])) && p() && e('6'); // 根据需求查看任务数量统计
|
||||
r($task->getListByStoryTest($storyIdList[0])) && p('5:name') && e('开发任务15'); // 获取未关联需求的任务
|
||||
r($task->getListByStoryTest($storyIdList[1])) && p('1:name') && e('开发任务11'); // 获取关联需求ID=1的任务
|
||||
r($task->getListByStoryTest($storyIdList[2])) && p('3:name') && e('开发任务13'); // 获取关联需求ID=2的任务
|
||||
r($task->getListByStoryTest($storyIdList[3])) && p() && e('0'); // 获取关联需求ID=3的任务
|
||||
r(count($task->getListByStoryTest($storyIdList[0]))) && p() && e('4'); // 获取未关联需求的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[1]))) && p() && e('2'); // 获取关联需求ID=1的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[2]))) && p() && e('2'); // 获取关联需求ID=2的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[3]))) && p() && e('0'); // 获取关联需求ID=3的任务数量
|
||||
|
||||
r($task->getListByStoryTest($storyIdList[0], $executionIdList[0])) && p() && e('0'); // 获取未关联需求并且执行ID=3的任务
|
||||
r($task->getListByStoryTest($storyIdList[1], $executionIdList[0])) && p('1:name') && e('开发任务11'); // 获取关联需求ID=1并且执行ID=3的任务
|
||||
r($task->getListByStoryTest($storyIdList[2], $executionIdList[0])) && p('3:name') && e('开发任务13'); // 获取关联需求ID=2并且执行ID=3的任务
|
||||
r($task->getListByStoryTest($storyIdList[3], $executionIdList[0])) && p() && e('0'); // 获取关联需求ID=3并且执行ID=3的任务
|
||||
r(count($task->getListByStoryTest($storyIdList[0], $executionIdList[0]))) && p() && e('0'); // 获取未关联需求并且执行ID=3的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[1], $executionIdList[0]))) && p() && e('2'); // 获取关联需求ID=1并且执行ID=3的的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[2], $executionIdList[0]))) && p() && e('1'); // 获取关联需求ID=2并且执行ID=3的的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[3], $executionIdList[0]))) && p() && e('0'); // 获取关联需求ID=3并且执行ID=3的的任务数量
|
||||
|
||||
r($task->getListByStoryTest($storyIdList[0], $executionIdList[1])) && p('5:name') && e('开发任务15'); // 获取未关联需求并且执行ID=4的任务
|
||||
r($task->getListByStoryTest($storyIdList[1], $executionIdList[1])) && p() && e('0'); // 获取关联需求ID=1并且执行ID=4的任务
|
||||
r($task->getListByStoryTest($storyIdList[2], $executionIdList[1])) && p('4:name') && e('开发任务14'); // 获取关联需求ID=2并且执行ID=4的任务
|
||||
r($task->getListByStoryTest($storyIdList[3], $executionIdList[1])) && p() && e('0'); // 获取关联需求ID=3并且执行ID=4的任务
|
||||
r(count($task->getListByStoryTest($storyIdList[0], $executionIdList[1]))) && p() && e('2'); // 获取未关联需求并且执行ID=4的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[1], $executionIdList[1]))) && p() && e('0'); // 获取关联需求ID=1并且执行ID=4的的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[2], $executionIdList[1]))) && p() && e('1'); // 获取关联需求ID=2并且执行ID=4的的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[3], $executionIdList[1]))) && p() && e('0'); // 获取关联需求ID=3并且执行ID=4的的任务数量
|
||||
|
||||
r($task->getListByStoryTest($storyIdList[0], $executionIdList[2])) && p() && e('0'); // 获取未关联需求并且执行ID=6的任务
|
||||
r($task->getListByStoryTest($storyIdList[1], $executionIdList[2])) && p() && e('0'); // 获取关联需求ID=1并且执行ID=6的任务
|
||||
r($task->getListByStoryTest($storyIdList[2], $executionIdList[2])) && p() && e('0'); // 获取关联需求ID=2并且执行ID=6的任务
|
||||
r($task->getListByStoryTest($storyIdList[3], $executionIdList[2])) && p() && e('0'); // 获取关联需求ID=3并且执行ID=6的任务
|
||||
r(count($task->getListByStoryTest($storyIdList[0], $executionIdList[2]))) && p() && e('0'); // 获取未关联需求并且执行ID=6的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[1], $executionIdList[2]))) && p() && e('0'); // 获取关联需求ID=1并且执行ID=6的的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[2], $executionIdList[2]))) && p() && e('0'); // 获取关联需求ID=2并且执行ID=6的的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[3], $executionIdList[2]))) && p() && e('0'); // 获取关联需求ID=3并且执行ID=6的的任务数量
|
||||
|
||||
r($task->getListByStoryTest($storyIdList[0], $executionIdList[0], $projectIdList[0])) && p() && e('0'); // 获取未关联需求并且执行ID=3、项目ID=1的任务
|
||||
r($task->getListByStoryTest($storyIdList[1], $executionIdList[0], $projectIdList[0])) && p('2:name') && e('开发任务12'); // 获取关联需求ID=1并且执行ID=3、项目ID=1的任务
|
||||
r($task->getListByStoryTest($storyIdList[2], $executionIdList[0], $projectIdList[0])) && p('3:name') && e('开发任务13'); // 获取关联需求ID=2并且执行ID=3、项目ID=1的任务
|
||||
r($task->getListByStoryTest($storyIdList[3], $executionIdList[0], $projectIdList[0])) && p() && e('0'); // 获取关联需求ID=3并且执行ID=3、项目ID=1的任务
|
||||
r(count($task->getListByStoryTest($storyIdList[0], $executionIdList[0], $projectIdList[0]))) && p() && e('0'); // 获取未关联需求并且执行ID=3、项目ID=1的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[1], $executionIdList[0], $projectIdList[0]))) && p() && e('2'); // 获取关联需求ID=1并且执行ID=3、项目ID=1的的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[2], $executionIdList[0], $projectIdList[0]))) && p() && e('1'); // 获取关联需求ID=2并且执行ID=3、项目ID=1的的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[3], $executionIdList[0], $projectIdList[0]))) && p() && e('0'); // 获取关联需求ID=3并且执行ID=3、项目ID=1的的任务数量
|
||||
|
||||
r($task->getListByStoryTest($storyIdList[0], $executionIdList[0], $projectIdList[1])) && p() && e('0'); // 获取未关联需求并且执行ID=3、项目ID=2的任务
|
||||
r($task->getListByStoryTest($storyIdList[1], $executionIdList[0], $projectIdList[1])) && p() && e('0'); // 获取关联需求ID=1并且执行ID=3、项目ID=2的任务
|
||||
r($task->getListByStoryTest($storyIdList[2], $executionIdList[0], $projectIdList[1])) && p() && e('0'); // 获取关联需求ID=2并且执行ID=3、项目ID=2的任务
|
||||
r($task->getListByStoryTest($storyIdList[3], $executionIdList[0], $projectIdList[1])) && p() && e('0'); // 获取关联需求ID=3并且执行ID=3、项目ID=2的任务
|
||||
r(count($task->getListByStoryTest($storyIdList[0], $executionIdList[0], $projectIdList[1]))) && p() && e('0'); // 获取未关联需求并且执行ID=3、项目ID=2的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[1], $executionIdList[0], $projectIdList[1]))) && p() && e('0'); // 获取关联需求ID=1并且执行ID=3、项目ID=2的的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[2], $executionIdList[0], $projectIdList[1]))) && p() && e('0'); // 获取关联需求ID=2并且执行ID=3、项目ID=2的的任务数量
|
||||
r(count($task->getListByStoryTest($storyIdList[3], $executionIdList[0], $projectIdList[1]))) && p() && e('0'); // 获取关联需求ID=3并且执行ID=3、项目ID=2的的任务数量
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
title: zt_task
|
||||
author: Shujie Tian
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-100
|
||||
- field: project
|
||||
range: 1
|
||||
- field: execution
|
||||
range: 3{3},4{3},5{6}
|
||||
- field: module
|
||||
range: 0{3},1{3},2{3},3{3}
|
||||
- field: story
|
||||
range: 1{2},2{2},0{8}
|
||||
- field: consumed
|
||||
range: 0,2{4},0{3},3
|
||||
- field: parent
|
||||
range: "0{5},`-1`,6,0{2}"
|
||||
- field: status
|
||||
range: "wait,doing,done,cancel,closed,wait{3},doing"
|
||||
- field: mode
|
||||
range: "[]{7},linear,multi"
|
||||
- field: deleted
|
||||
range: 0{9},1{3}
|
||||
- field: assignedTo
|
||||
range: "[],admin{2},[]{3}"
|
||||
- field: mailto
|
||||
fields:
|
||||
- field: mailto1
|
||||
range: "[]{3},admin,[]{2}"
|
||||
postfix: ","
|
||||
- field: mailto2
|
||||
range: "[]{2},user1{3}"
|
||||
@@ -587,26 +587,17 @@ class taskTest
|
||||
* Test get task pairs of a story.
|
||||
*
|
||||
* @param int $storyID
|
||||
* @param int $count
|
||||
* @param int $executionID
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return array
|
||||
* @return object[]
|
||||
*/
|
||||
public function getListByStoryTest($storyID, $count)
|
||||
public function getListByStoryTest(int $storyID, int $executionID = 0, int $projectID = 0)
|
||||
{
|
||||
$object = $this->objectModel->getListByStory($storyID);
|
||||
if(dao::isError())
|
||||
{
|
||||
$error = dao::getError();
|
||||
return $error;
|
||||
}
|
||||
elseif($count == "1")
|
||||
{
|
||||
return count($object);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $object;
|
||||
}
|
||||
$object = $this->objectModel->getListByStory($storyID, $executionID, $projectID);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user