From cf9d094a2264c8ae548d82688a06a52bfd6c03ba Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 21 Aug 2023 16:35:34 +0800 Subject: [PATCH] + Add case of the getExportTasks. --- module/task/model.php | 2 +- module/task/test/model/getexporttasks.php | 25 +++++++++++++++++++++++ module/task/test/task.class.php | 24 ++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 module/task/test/model/getexporttasks.php diff --git a/module/task/model.php b/module/task/model.php index ec815bf4f0..96ebee4693 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -1708,7 +1708,7 @@ class taskModel extends model $tasks = array(); if($this->session->taskOnlyCondition) { - $tasks = $this->dao->select('*')->from(TABLE_TASK)->alias('t1')->where($this->session->taskQueryCondition) + $tasks = $this->dao->select('*')->from(TABLE_TASK)->alias('t1')->where($this->session->taskOnlyCondition) ->beginIF($this->post->exportType == 'selected')->andWhere('t1.id')->in($this->cookie->checkedItem)->fi() ->orderBy($sort) ->fetchAll('id'); diff --git a/module/task/test/model/getexporttasks.php b/module/task/test/model/getexporttasks.php new file mode 100755 index 0000000000..119411746f --- /dev/null +++ b/module/task/test/model/getexporttasks.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +config('task', true)->gen(30); + +/** + +title=taskModel->getExportTasks(); +timeout=0 +cid=1 + +*/ + +$orderByList = array('id_desc', 'pri_asc'); + +$taskTester = new taskTest(); + +r($taskTester->getExportTasksTest($orderByList[0])) && p() && e('0'); // 按照id倒序获取任务数据 +r($taskTester->getExportTasksTest($orderByList[1])) && p() && e('0'); // 按照优先级正序获取任务数据 +r($taskTester->getExportTasksTest($orderByList[0], true)) && p('1:name') && e('开发任务39'); // 按照条件获取任务数据 +r($taskTester->getExportTasksTest($orderByList[0], false, true)) && p('1:name') && e('开发任务39'); // 按照条件获取任务数据 +r($taskTester->getExportTasksTest($orderByList[0], false, true, 'selected')) && p('3:name') && e('开发任务13'); // 按照条件获取任务数据 diff --git a/module/task/test/task.class.php b/module/task/test/task.class.php index 3ec9a72b62..32f59824ab 100755 --- a/module/task/test/task.class.php +++ b/module/task/test/task.class.php @@ -2027,4 +2027,28 @@ class taskTest $tasks = $this->objectModel->dao->select('*')->from(TABLE_TASK)->where('id')->in($taskIdList)->fetchAll(); return $this->objectModel->processExportTasks($tasks); } + + /** + * 获取导出的任务数据。 + * Get export task information. + * + * @param string $orderBy + * @param bool $taskOnlyCondition + * @param bool $taskQueryCondition + * @param string $exportType + * @access public + * @return object[] + */ + public function getExportTasksTest(string $orderBy, bool $taskOnlyCondition = false, bool $taskQueryCondition = false, string $exportType = ''): array + { + if($taskOnlyCondition) $this->objectModel->session->set('taskOnlyCondition', '1=1'); + if($taskQueryCondition) $this->objectModel->session->set('taskQueryCondition', '1=1'); + if($exportType) + { + $_POST['exportType'] = $exportType; + $_COOKIE['checkedItem'] = '1,2,3'; + } + + return $this->objectModel->getExportTasks($orderBy); + } }