From d409d45e5f45ac1e537419cbedb6897b241bfd1c Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 18 Aug 2023 16:31:50 +0800 Subject: [PATCH] + Add fetchPairs method. --- module/execution/model.php | 24 +++++++++++ module/execution/test/model/fetchpairs.php | 47 ++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100755 module/execution/test/model/fetchpairs.php diff --git a/module/execution/model.php b/module/execution/model.php index 9f52cb4f41..4639c8e79b 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1879,6 +1879,30 @@ class executionModel extends model return $executionQuery; } + /** + * 获取执行id=>name的键值对。 + * Get an array of execution id:name. + * + * @param int $projectID + * @param string $type + * @param bool $filterMulti + * @param bool $queryAll + * @access public + * @return array + */ + public function fetchPairs($projectID = 0, $type = 'all', $filterMulti = true, $queryAll = false): array + { + return $this->dao->select('id,name')->from(TABLE_EXECUTION) + ->where('deleted')->eq(0) + ->andWhere('vision')->eq($this->config->vision) + ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi() + ->beginIF($type == 'all')->andWhere('type')->in('stage,sprint,kanban')->fi() + ->beginIF($type != 'all')->andWhere('type')->in($type)->fi() + ->beginIF($filterMulti)->andWhere('multiple')->eq('1')->fi() + ->beginIF(!$queryAll && !$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi() + ->fetchPairs(); + } + /** * 获取执行列表信息。 * Get execution list information. diff --git a/module/execution/test/model/fetchpairs.php b/module/execution/test/model/fetchpairs.php new file mode 100755 index 0000000000..59b5d03e5d --- /dev/null +++ b/module/execution/test/model/fetchpairs.php @@ -0,0 +1,47 @@ +#!/usr/bin/env php +gen(5); +su('admin'); + +zdTable('project')->config('execution', true)->gen(30); + +/** + +title=测试executionModel->fetchPairs(); +timeout=0 +cid=1 + +*/ + +$projectIdList = array(0, 11, 1); +$typeList = array('all', 'sprint', 'stage', 'kanban'); + +global $tester; +$executionModel = $tester->loadModel('execution'); +$allExecutions = $executionModel->fetchPairs($projectIdList[0], $typeList[0], false, true); +$multipleExecutions = $executionModel->fetchPairs($projectIdList[0], $typeList[0], true, true); +$canViewExecutions = $executionModel->fetchPairs($projectIdList[0], $typeList[0], true, false); +$projectExecutions = $executionModel->fetchPairs($projectIdList[1], $typeList[0], true, false); +$notExistProjectExecutions = $executionModel->fetchPairs($projectIdList[2], $typeList[0], true, false); +$sprints = $executionModel->fetchPairs($projectIdList[0], $typeList[1], true, false); +$stages = $executionModel->fetchPairs($projectIdList[0], $typeList[2], true, false); +$kanbans = $executionModel->fetchPairs($projectIdList[0], $typeList[3], true, false); + +r(count($allExecutions)) && p() && e('26'); // 获取系统内全部执行的数量 +r(count($multipleExecutions)) && p() && e('24'); // 获取系统内全部非影子执行的数量 +r(count($canViewExecutions)) && p() && e('24'); // 获取系统内全部有权限执行的数量 +r(count($projectExecutions)) && p() && e('3'); // 获取敏捷项目下的执行的数量 +r(count($notExistProjectExecutions)) && p() && e('0'); // 获取不存在项目下的执行的数量 +r(count($sprints)) && p() && e('3'); // 获取系统内全部迭代的数量 +r(count($stages)) && p() && e('18'); // 获取系统内全部阶段的数量 +r(count($kanbans)) && p() && e('3'); // 获取系统内全部看板的数量 + +r($allExecutions) && p('101') && e('迭代5'); // 获取系统内全部执行 +r($multipleExecutions) && p('101') && e('迭代5'); // 获取系统内全部非影子执行 +r($canViewExecutions) && p('101') && e('迭代5'); // 获取系统内全部有权限执行 +r($projectExecutions) && p('101') && e('迭代5'); // 获取敏捷项目下的执行 +r($notExistProjectExecutions) && p() && e('0'); // 获取敏捷项目下的执行 +r($sprints) && p('101') && e('迭代5'); // 获取系统内全部迭代 +r($stages) && p('106') && e('阶段10'); // 获取系统内全部阶段 +r($kanbans) && p('124') && e('看板28'); // 获取系统内全部看板