diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index 4dd220370d..3ec8b5df29 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -1229,6 +1229,39 @@ class executionTest } } + + /** + * 转入任务到指定的执行。 + * Import tasks. + * + * @param int $executionID + * @param int $count + * @param array $taskIdList + * @access public + * @return array|int + */ + public function afterImportTaskTest(int $executionID, int $count, array $taskIdList = array()): array|int + { + $dateExceed = array(); + $taskStories = array(); + $parents = array(); + $execution = $this->executionModel->fetchByID($executionID); + $tasks = $this->executionModel->loadModel('task')->getByIdList($taskIdList); + $assignedToes = array(); + foreach($tasks as $task) + { + /* Save the assignedToes and stories, should linked to execution. */ + $assignedToes[$task->assignedTo] = $task->execution; + $taskStories[$task->story] = $task->story; + if($task->parent < 0) $parents[$task->id] = $task->id; + } + + $this->executionModel->afterImportTask($execution, $parents, $assignedToes, $taskStories); + + $teams = $this->executionModel->dao->select('*')->from(TABLE_TEAM)->where('type')->eq('execution')->andWhere('root')->eq($executionID)->fetchAll(); + return $count ? count($teams) : $teams; + } + /** * 统计执行的需求数、任务数、Bug数。 * Statistics the number of stories, tasks, and bugs for the execution. diff --git a/module/execution/test/model/afterimporttask.php b/module/execution/test/model/afterimporttask.php new file mode 100644 index 0000000000..b6555c0131 --- /dev/null +++ b/module/execution/test/model/afterimporttask.php @@ -0,0 +1,39 @@ +#!/usr/bin/env php +config('execution')->gen(30); +$team = zdTable('team')->config('team'); +$team->account->range('admin'); +$team->gen(30); + +$task = zdTable('task')->config('task'); +$task->project->range('11,60,100'); +$task->execution->range('101,106,124'); +$task->assignedTo->range('admin'); +$task->gen(30); + +su('admin'); + +/** + +title=测试executionModel->afterImportTask(); +timeout=0 +cid=1 + +*/ + +$executionIDList = array(101, 106, 124); +$sprintTasks = array(1, 3, 5, 10, 13, 19, 22, 28); +$stageTasks = array(2, 4, 6, 7, 8, 11, 14, 16); +$kanbanTasks = array(9, 12, 18); +$count = array(0, 1); + +$execution = new executionTest(); +r($execution->afterImportTaskTest($executionIDList[0], $count[0], $sprintTasks)) && p('0:root,account') && e('101,admin'); // 敏捷执行导入任务后团队成员信息 +r($execution->afterImportTaskTest($executionIDList[1], $count[0], $stageTasks)) && p('0:root,account') && e('106,admin'); // 瀑布执行导入任务后团队成员信息 +r($execution->afterImportTaskTest($executionIDList[2], $count[0], $kanbanTasks)) && p('0:root,account') && e('124,admin'); // 看板执行导入任务后团队成员信息 +r($execution->afterImportTaskTest($executionIDList[0], $count[1], $sprintTasks)) && p() && e('1'); // 敏捷执行导入任务后团队成员的数量 +r($execution->afterImportTaskTest($executionIDList[1], $count[1], $stageTasks)) && p() && e('1'); // 瀑布执行导入任务后团队成员的数量 +r($execution->afterImportTaskTest($executionIDList[2], $count[1], $kanbanTasks)) && p() && e('1'); // 看板执行导入任务后团队成员的数量