From d9baacd8b82187fd38be0aa7d36f7eae0ccb9e9b Mon Sep 17 00:00:00 2001 From: liugang Date: Tue, 19 Sep 2023 15:58:20 +0800 Subject: [PATCH] + testtaskZen: add a method to get cases to run. --- module/testtask/zen.php | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/module/testtask/zen.php b/module/testtask/zen.php index 549481bb6a..7d1a01adab 100644 --- a/module/testtask/zen.php +++ b/module/testtask/zen.php @@ -3,7 +3,7 @@ class testtaskZen extends testtask { /** * 根据不同情况设置菜单。 - * Set menu according different situations. + * Set menu according to different situations. * * @param int $productID * @param int $branch @@ -324,6 +324,43 @@ class testtaskZen extends testtask return $this->loadModel('product')->getPairs('', 0, '', 'all'); } + /** + * 获取批量执行的用例。 + * Get cases to run. + * + * @param int $productID + * @param string $orderBy + * @param string $from + * @param int $testID + * @param string $confirm + * @param array $caseIdList + * @access protected + * @return array + */ + protected function prepareCasesForBatchRun(int $productID, string $orderBy, string $from, int $taskID, string $confirm, array $caseIdList): array + { + $this->setMenu($productID, 0, $this->session->project, $this->session->execution); + + $cases = $this->dao->select('*')->from(TABLE_CASE) + ->where('id')->in($caseIdList) + ->beginIF($confirm == 'yes')->andWhere('auto')->ne('auto')->fi() + ->orderBy($orderBy) + ->fetchAll('id'); + if($from != 'testtask') return $cases; + + /* 如果批量执行的用例来自测试单,检查这些用例的版本,如果不是最新版就移除它们。*/ + /* If cases come from a testtask, check the version of these cases, if not the latest version, remove them. */ + $runs = $this->dao->select('`case`, version')->from(TABLE_TESTRUN) + ->where('`case`')->in(array_keys($cases)) + ->andWhere('task')->eq($taskID) + ->fetchPairs(); + foreach($cases as $caseID => $case) + { + if(isset($runs[$caseID]) && $runs[$caseID] < $case->version) unset($cases[$caseID]); + } + return $cases; + } + /** * 处理测试用例的跨行合并属性供前端组件分组使用。 * Process the rowspan property of cases for use by front-end component groupings.