From 6326d59ea44a43a1e26b0544077f5954df841e95 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 8 May 2023 19:04:17 +0800 Subject: [PATCH] * Add test case for createtestchildtasks method. --- .../task/test/model/createtestchildtasks.php | 43 +++++++++++++++++++ module/task/test/task.class.php | 20 +++++++++ 2 files changed, 63 insertions(+) create mode 100755 module/task/test/model/createtestchildtasks.php diff --git a/module/task/test/model/createtestchildtasks.php b/module/task/test/model/createtestchildtasks.php new file mode 100755 index 0000000000..4b5225c5de --- /dev/null +++ b/module/task/test/model/createtestchildtasks.php @@ -0,0 +1,43 @@ +#!/usr/bin/env php +id->range('1'); +$task->type->range('test'); +$task->name->range('测试任务1'); +$task->status->range('wait'); +$task->gen(1); + +$story = zdTable('story'); +$story->id->range('1-5'); +$story->product->range('1'); +$story->title->range('1-5')->prefix('需求'); +$story->type->range('story'); +$story->gen(5); + +/** + +title=测试taskModel->createTestChildTasks(); +timeout=0 +cid=1 + +*/ + +$testTasks[2] = new stdclass(); +$testTasks[2]->name = '测试子任务1'; +$testTasks[2]->type = 'test'; +$testTasks[2]->mailto = ''; + +$testTasks[3] = new stdclass(); +$testTasks[3]->name = '测试子任务2'; +$testTasks[3]->type = 'test'; +$testTasks[3]->mailto = ''; + +$taskTester = new taskTest(); +r($taskTester->createTestChildTasksTest()) && p() && e('0'); // 测试空数据 +r($taskTester->createTestChildTasksTest(0, $testTasks)) && p('name') && e('测试研发需求 #3 需求3'); // 测试任务ID为空的情况 +r($taskTester->createTestChildTasksTest(1, array())) && p() && e('0'); // 测试子测试任务的数据为空的情况 +r($taskTester->createTestChildTasksTest(1, $testTasks)) && p('name') && e('测试研发需求 #3 需求3'); // 测试创建任务ID为1的子测试任务 diff --git a/module/task/test/task.class.php b/module/task/test/task.class.php index 4b6a3d7c9b..21a0faf55a 100644 --- a/module/task/test/task.class.php +++ b/module/task/test/task.class.php @@ -1865,4 +1865,24 @@ class taskTest return array('minStatus' => $minStatus, 'taskTeamMember' => !empty($taskTeamMember) ? implode('|', $taskTeamMember) : '0'); } } + + /** + * Create a subtask for the test type story with the story. + * + * @param int $taskID + * @param array $testTasks + * @access public + * @return void + */ + public function createTestChildTasksTest($taskID = 0, $testTasks = array()) + { + global $tester; + $_SERVER['HTTP_HOST'] = $tester->config->db->host; + + $this->objectModel->createTestChildTasks($taskID, $testTasks); + if(dao::isError()) return dao::getError(); + + $lastTaskID = $tester->dao->select('objectID')->from(TABLE_ACTION)->where('objectType')->eq('task')->andWhere('action')->eq('Opened')->orderBy('`date` desc')->fetch('objectID'); + return $this->objectModel->getByID($lastTaskID); + } }