From 611fe9638b2f91fd2a7d0374cba900706c12f285 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Fri, 13 Sep 2024 16:02:04 +0800 Subject: [PATCH] * [bug#54826] Set bug title and build when testcase to bug in tutorial. --- module/bug/model.php | 2 +- module/build/model.php | 2 ++ module/tutorial/model.php | 58 +++++++++++++++++++++++++++------------ 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index 61e59b3dbc..45adca42bb 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1265,7 +1265,7 @@ class bugModel extends model */ public function getBugInfoFromResult(int $resultID, int $caseID = 0, string $stepIdList = ''): array { - $result = $this->dao->findById($resultID)->from(TABLE_TESTRESULT)->fetch(); + $result = common::isTutorialMode() ? $this->loadModel('tutorial')->getResult() : $this->dao->findById($resultID)->from(TABLE_TESTRESULT)->fetch(); if(!$result) return array(); if($caseID > 0) diff --git a/module/build/model.php b/module/build/model.php index 3675dc1108..0828b055c4 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -255,6 +255,8 @@ class buildModel extends model */ public function getBuildPairs(array|int $productIdList, string|int $branch = 'all', string $params = 'noterminate, nodone', int $objectID = 0, string $objectType = 'execution', string $buildIdList = '', bool $replace = true): array { + if(common::isTutorialMode()) return $this->loadModel('tutorial')->getBuildPairs(); + $sysBuilds = array(); if(strpos($params, 'notrunk') === false) $sysBuilds = array('trunk' => $this->lang->trunk); diff --git a/module/tutorial/model.php b/module/tutorial/model.php index 996de1a6fd..164dc03f0a 100644 --- a/module/tutorial/model.php +++ b/module/tutorial/model.php @@ -925,6 +925,18 @@ class tutorialModel extends model return $builds; } + /** + * 获取新手模式版本键值对。 + * Get build pairs. + * + * @access public + * @return array + */ + public function getBuildPairs(): array + { + return array(1 => 'Test build'); + } + /** * 获取新手模式测试单。 * Get run. @@ -1059,15 +1071,14 @@ class tutorialModel extends model /** * 获取新手模式用例执行结果。 - * Get results. + * Get result. * * @access public - * @return array + * @return object */ - public function getResults(): array + public function getResult(): object { $result = new stdClass(); - $result->id = 1; $result->run = 0; $result->case = 1; @@ -1075,6 +1086,31 @@ class tutorialModel extends model $result->job = 0; $result->compile = 0; $result->caseResult = 'fail'; + $result->stepResults = ''; + $result->ZTFResult = ''; + $result->node = 0; + $result->lastRunner = $this->app->user->account; + $result->date = helper::now(); + $result->duration = 0; + $result->xml = ''; + $result->deploy = 0; + $result->build = 0; + $result->task = 0; + $result->nodeName = ''; + $result->files = array(); + return $result; + } + + /** + * 获取新手模式用例执行结果。 + * Get results. + * + * @access public + * @return array + */ + public function getResults(): array + { + $result = $this->getResult(); $result->stepResults = array( 1 => array( 'id' => 1, @@ -1105,19 +1141,7 @@ class tutorialModel extends model 'files' => array() ) ); - - $result->ZTFResult = ''; - $result->node = 0; - $result->lastRunner = $this->app->user->account; - $result->date = helper::now(); - $result->duration = 0; - $result->xml = ''; - $result->deploy = 0; - $result->build = 0; - $result->task = 0; - $result->nodeName = ''; - $result->files = array(); - return array(1 => $result); + return array($result->id => $result); } /**