From e6ede17937d3078ad3e2ef9f331f3b704c7882e5 Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 10 Jul 2025 16:48:57 +0800 Subject: [PATCH] * [refac] refactor the assignCasesAndScenesForBrowse method. --- module/testcase/control.php | 2 +- module/testcase/zen.php | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/module/testcase/control.php b/module/testcase/control.php index 83cfd7faa1..8577b9bd1f 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -122,7 +122,7 @@ class testcase extends control $actionURL = $this->createLink($currentModule, $currentMethod, $projectParam . "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID" . $suffixParam); $this->testcaseZen->buildBrowseSearchForm($productID, $queryID, $projectID, $actionURL); - $this->testcaseZen->assignCasesAndScenesForBrowse($productID, $branch, $browseType, ($browseType == 'bysearch' ? $queryID : $suiteID), $moduleID, $caseType, $orderBy, $recTotal, $recPerPage, $pageID, $from); + $this->testcaseZen->assignCasesForBrowse($productID, $branch, $browseType, ($browseType == 'bysearch' ? $queryID : $suiteID), $moduleID, $caseType, $orderBy, $recTotal, $recPerPage, $pageID, $from); $this->testcaseZen->assignModuleTreeForBrowse($productID, $branch, $projectID); $this->testcaseZen->assignProductAndBranchForBrowse($productID, $branch, $projectID); $this->testcaseZen->assignForBrowse($productID, $branch, $browseType, $projectID, $param, $moduleID, $suiteID, $caseType); diff --git a/module/testcase/zen.php b/module/testcase/zen.php index 3069e495ff..a9240a1480 100755 --- a/module/testcase/zen.php +++ b/module/testcase/zen.php @@ -498,8 +498,8 @@ class testcaseZen extends testcase } /** - * 指定用例列表的场景和用例。 - * Assign scenes and cases for browse page. + * 指定浏览用例页面的用例列表。 + * Assign cases for browse page. * * @param int $productID * @param string $branch @@ -514,24 +514,18 @@ class testcaseZen extends testcase * @access protected * @return void */ - protected function assignCasesAndScenesForBrowse(int $productID, string $branch, string $browseType, int $queryID, int $moduleID, string $caseType, string $orderBy, int $recTotal, int $recPerPage, int $pageID): void + protected function assignCasesForBrowse(int $productID, string $branch, string $browseType, int $queryID, int $moduleID, string $caseType, string $orderBy, int $recTotal, int $recPerPage, int $pageID, string $from = 'testcase'): void { $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); - $cases = array(); - $scenes = array(); - $sort = common::appendOrder($orderBy); + $sort = common::appendOrder($orderBy); if(strpos($sort, 'caseID') !== false) $sort = str_replace('caseID', 'id', $sort); - $cases = $this->testcase->getTestCases($productID, $branch, $browseType, $queryID, $moduleID, $caseType, $auto = 'no', $sort, $pager); + + $cases = $this->testcase->getTestCases($productID, $branch, $browseType, $queryID, $moduleID, $caseType, 'no', $sort, $pager, $from); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false); - - $sceneCount = count($scenes); - $caseCount = count($cases); - $summary = sprintf($browseType == 'onlyscene' ? $this->lang->testcase->summaryScene : $this->lang->testcase->summary, $sceneCount, $caseCount); - - $scenes = $this->testcase->preProcessScenesForBrowse($scenes); - $cases = $this->testcase->preProcessCasesForBrowse($cases); + $cases = $this->loadModel('story')->checkNeedConfirm($cases); + $cases = $this->testcase->appendData($cases); if($this->config->edition != 'open') { @@ -539,10 +533,9 @@ class testcaseZen extends testcase foreach($cases as $caseID => $case) $case->relatedObject = zget($caseRelatedObjectList, $caseID, 0); } - $this->view->cases = array_merge($scenes, $cases); + $this->view->cases = $this->processCasesForBrowse($cases); $this->view->orderBy = $orderBy; $this->view->pager = $pager; - $this->view->summary = $summary; } /**