diff --git a/module/task/tao.php b/module/task/tao.php index 33826918ba..2605993aa3 100644 --- a/module/task/tao.php +++ b/module/task/tao.php @@ -880,7 +880,7 @@ class taskTao extends taskModel * * @param int $parentID * @param object $data - * @param string $action + * @param string $action Activated * @param string $comment * @access protected * @return void diff --git a/module/task/test/tao/updatechildrenbyparent.php b/module/task/test/tao/updatechildrenbyparent.php new file mode 100755 index 0000000000..56ecabb299 --- /dev/null +++ b/module/task/test/tao/updatechildrenbyparent.php @@ -0,0 +1,36 @@ +#!/usr/bin/env php +gen(0); +zdTable('task')->config('task', true)->gen(10); + +/** + +title=taskModel->updateChildrenByParent(); +timeout=0 +cid=1 + +*/ + +$parentIdList = array(1, 6, 7); +$actionList = array('Started', 'Activated', 'Closed'); +$commentList = array('', '这是一条备注'); + +$taskTester = new taskTest(); + +r($taskTester->updateChildrenByParentTest($parentIdList[0], $actionList[0], $commentList[0])) && p() && e('0'); // 测试开始普通任务 +r($taskTester->updateChildrenByParentTest($parentIdList[0], $actionList[1], $commentList[0])) && p() && e('0'); // 测试激活普通任务 +r($taskTester->updateChildrenByParentTest($parentIdList[0], $actionList[2], $commentList[0])) && p() && e('0'); // 测试关闭普通任务 +r($taskTester->updateChildrenByParentTest($parentIdList[0], $actionList[0], $commentList[1])) && p() && e('0'); // 测试开始普通任务并留备注 + +r($taskTester->updateChildrenByParentTest($parentIdList[1], $actionList[0], $commentList[0])) && p('action') && e('started'); // 测试开始父任务 +r($taskTester->updateChildrenByParentTest($parentIdList[1], $actionList[1], $commentList[0])) && p('action') && e('activated'); // 测试激活父任务 +r($taskTester->updateChildrenByParentTest($parentIdList[1], $actionList[2], $commentList[0])) && p('action') && e('closed'); // 测试关闭父任务 +r($taskTester->updateChildrenByParentTest($parentIdList[1], $actionList[0], $commentList[1])) && p('action') && e('started'); // 测试开始父任务并留备注 + +r($taskTester->updateChildrenByParentTest($parentIdList[2], $actionList[0], $commentList[0])) && p() && e('0'); // 测试开始子任务 +r($taskTester->updateChildrenByParentTest($parentIdList[2], $actionList[1], $commentList[0])) && p() && e('0'); // 测试激活子任务 +r($taskTester->updateChildrenByParentTest($parentIdList[2], $actionList[2], $commentList[0])) && p() && e('0'); // 测试关闭子任务 +r($taskTester->updateChildrenByParentTest($parentIdList[2], $actionList[0], $commentList[1])) && p() && e('0'); // 测试开始子任务并留备注 diff --git a/module/task/test/task.class.php b/module/task/test/task.class.php index 07d7d2d075..2d41fcddf2 100755 --- a/module/task/test/task.class.php +++ b/module/task/test/task.class.php @@ -2208,4 +2208,29 @@ class taskTest return $this->objectModel->dao->select('action')->from(TABLE_ACTION)->where('objectType')->eq('task')->andWhere('objectID')->eq($oldParentTask->id)->orderBy('`id` desc')->fetch();; } + + /** + * 通过父任务更新子任务。 + * Update chilren task by parent task. + * + * @param int $parentID + * @param string $action + * @param string $comment + * @access public + * @return object|false + */ + public function updateChildrenByParentTest(int $parentID, string $action, string $comment): object|false + { + $task = $this->objectModel->getByID($parentID); + + $data = new stdclass(); + $data->name = $task->name; + $data->pri = $task->pri; + $data->status = $task->status; + + $this->objectModel->updateChildrenByParent($parentID, $data, $action, $comment); + + $childID = $this->objectModel->dao->select('id')->from(TABLE_TASK)->where('parent')->eq($parentID)->fetch('id'); + return $this->objectModel->dao->select('action')->from(TABLE_ACTION)->where('objectType')->eq('task')->andWhere('objectID')->eq($childID)->orderBy('id_desc')->fetch(); + } }