From a5dcde12bae5d076db3ccefb1232c29c13f7b981 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 8 Sep 2023 10:25:31 +0800 Subject: [PATCH] * Refactor getIdList method and case. --- module/execution/model.php | 11 ++++++----- module/execution/test/execution.class.php | 11 ++++++----- module/execution/test/model/getidlist.php | 11 ++--------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index d8c241062b..9e8be05635 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1576,7 +1576,7 @@ class executionModel extends model * @access public * @return array */ - public function getByIdList($executionIdList = array(), $mode = '') + public function getByIdList($executionIdList = array(), $mode = ''): array { return $this->dao->select('*')->from(TABLE_EXECUTION) ->where('id')->in($executionIdList) @@ -1704,21 +1704,22 @@ class executionModel extends model } /** + * 获取给定项目下所有执行的Id列表。 * Get execution id list by project. * - * @param int $projectID - * @param int $status all|undone|wait|doing|suspended|closed + * @param int $projectID + * @param string $status all|undone|wait|doing|suspended|closed * @access public * @return array */ - public function getIdList($projectID, $status = 'all') + public function getIdList(int $projectID, string $status = 'all') { return $this->dao->select('id')->from(TABLE_EXECUTION) ->where('type')->in('sprint,stage,kanban') ->andWhere('deleted')->eq('0') ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi() ->beginIF($status == 'undone')->andWhere('status')->notIN('done,closed')->fi() - ->beginIF($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->fi() + ->beginIF(!in_array($status, array('all', 'undone')))->andWhere('status')->in($status)->fi() ->fetchPairs('id', 'id'); } diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index 585a5fc149..7d795013d2 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -780,14 +780,15 @@ class executionTest } /** - * function getIdList test execution + * 获取给定项目下所有执行的Id列表。 + * Get execution id list by project. * - * @param string $projectID - * @param string $count + * @param int $projectID + * @param int $count * @access public - * @return array + * @return array|int */ - public function getIdListTest($projectID, $count) + public function getIdListTest(int $projectID, int $count): array|int { $object = $this->executionModel->getIdList($projectID); diff --git a/module/execution/test/model/getidlist.php b/module/execution/test/model/getidlist.php index ba2a747ad7..eeac5b3964 100755 --- a/module/execution/test/model/getidlist.php +++ b/module/execution/test/model/getidlist.php @@ -35,20 +35,13 @@ $execution->gen(10); /** title=测试executionModel->getIdListTest(); +timeout=0 cid=1 -pid=1 - -敏捷项目下执行id查询 >> 5 -瀑布项目下执行id查询 >> 7 -看板项目下执行id查询 >> 9 -敏捷项目下执行id数量统计 >> 2 -敏捷项目下执行id数量统计 >> 2 -敏捷项目下执行id数量统计 >> 2 */ $projectIDList = array(2, 3, 4); -$count = array('0','1'); +$count = array(0, 1); $executionTester = new executionTest(); r($executionTester->getIdListTest($projectIDList[0],$count[0])) && p('5') && e('5'); // 敏捷项目下执行id查询