+ Add case of the getExportTasks.

This commit is contained in:
tianshujie
2023-08-21 16:35:49 +08:00
parent 3b32b93812
commit cf9d094a22
3 changed files with 50 additions and 1 deletions
+1 -1
View File
@@ -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');
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/task.class.php';
su('admin');
zdTable('task')->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'); // 按照条件获取任务数据
+24
View File
@@ -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);
}
}