diff --git a/module/bug/control.php b/module/bug/control.php index 4d8bcad84f..b5f540484f 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -132,8 +132,8 @@ class bug extends control $this->display(); } - /* 创建Bug。*/ - public function create($productID, $moduleID = 0) + /* 创建Bug。extras是其他的参数,key和value之间使用=连接,多个键值对之间使用,隔开。*/ + public function create($productID, $extras = '') { if(empty($this->products)) $this->locate($this->createLink('product', 'create')); @@ -146,13 +146,28 @@ class bug extends control die(js::locate($this->createLink('bug', 'browse', "productID={$this->post->product}&type=byModule¶m={$this->post->module}"), 'parent')); } - /* 设置当前的产品和模块。*/ - $productID = common::saveProductState($productID, key($this->products)); - $currentModuleID = (int)$moduleID; - - /* 设置菜单。*/ + /* 设置当前的产品,设置菜单。*/ + $productID = common::saveProductState($productID, key($this->products)); $this->bug->setMenu($this->products, $productID); + /* 初始化变量。*/ + $moduleID = 0; + $projectID = 0; + $taskID = 0; + $storyID = 0; + $buildID = 0; + $runID = 0; + $title = ''; + $steps = ''; + + /* 解析extra参数。*/ + $extras = str_replace(array(',', ' '), array('&', ''), $extras); + parse_str($extras); + + /* 如果设置了runID,获得最后一次的resultID。*/ + if($runID > 0) $resultID = $this->dao->select('id')->from(TABLE_TESTRESULT)->where('run')->eq($runID)->orderBy('id desc')->limit(1)->fetch('id'); + if(isset($resultID) and $resultID > 0) extract($this->bug->getBugInfoFromResult($resultID)); + /* 位置信息。*/ $this->view->header->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->create; $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]); @@ -161,11 +176,17 @@ class bug extends control $this->view->productID = $productID; $this->view->productName = $this->products[$productID]; $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $rooteModuleID = 0); - $this->view->currentModuleID = $currentModuleID; $this->view->stories = $this->story->getProductStoryPairs($productID); $this->view->users = $this->user->getPairs('noclosed'); $this->view->projects = $this->product->getProjectPairs($productID); $this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID); + $this->view->moduleID = $moduleID; + $this->view->projectID = $projectID; + $this->view->taskID = $taskID; + $this->view->storyID = $storyID; + $this->view->buildID = $buildID; + $this->view->title = $title; + $this->view->steps = $steps; $this->display(); } diff --git a/module/bug/lang/zh-cn.php b/module/bug/lang/zh-cn.php index b1aaec3fec..5122480c25 100644 --- a/module/bug/lang/zh-cn.php +++ b/module/bug/lang/zh-cn.php @@ -163,3 +163,7 @@ $lang->bug->files = '附件'; $lang->bug->field1 = 'field1'; $lang->bug->field2 = 'field2'; $lang->bug->feild3 = 'feild3'; + +$lang->bug->tblStep = "[步骤]\n"; +$lang->bug->tblResult = "[结果]\n"; +$lang->bug->tblExpect = "[期望]\n"; diff --git a/module/bug/model.php b/module/bug/model.php index 9cfa18d22a..e5e054382c 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -243,4 +243,34 @@ class bugModel extends model { return $this->dao->select('*')->from(TABLE_BUG)->where('project')->eq((int)$projectID)->orderBy($orderBy)->page($pager)->fetchAll(); } + + /* 通过某一次测试结果获得bug的标题和步骤。*/ + public function getBugInfoFromResult($resultID) + { + $title = ''; + $bugSteps = ''; + + $result = $this->dao->findById($resultID)->from(TABLE_TESTRESULT)->fetch(); + $run = $this->loadModel('testtask')->getRunById($result->run); + if($result and $result->caseResult == 'fail') + { + $title = $run->case->title; + $caseSteps = $run->case->steps; + $stepResults = unserialize($result->stepResults); + $bugSteps = $this->lang->bug->tblStep; + foreach($caseSteps as $key => $step) + { + $bugSteps .= ($key + 1) . '. ' .$step->desc . "\n"; + if($stepResults[$step->id]['result'] == 'fail') + { + $bugSteps .= $this->lang->bug->tblResult; + $bugSteps .= $stepResults[$step->id]['real'] . "\n"; + $bugSteps .= $this->lang->bug->tblExpect; + $bugSteps .= $step->expect; + break; + } + } + } + return array('title' => $title, 'steps' => $bugSteps); + } } diff --git a/module/bug/view/browse.html.php b/module/bug/view/browse.html.php index f5ad5cc6d6..6114b68902 100644 --- a/module/bug/view/browse.html.php +++ b/module/bug/view/browse.html.php @@ -64,7 +64,7 @@ function browseBySearch(active) ?>