+ add the feature of create bug from test result.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ function browseBySearch(active)
|
||||
?>
|
||||
</div>
|
||||
<div class='f-right'>
|
||||
<?php common::printLink('bug', 'create', "productID=$productID&moduleID=$moduleID", $lang->bug->create); ?>
|
||||
<?php common::printLink('bug', 'create', "productID=$productID&extra=moduleID=$moduleID", $lang->bug->create); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div id='querybox' class='<?php if($browseType !='bysearch') echo 'hidden';?>'><?php echo $searchForm;?></div>
|
||||
|
||||
@@ -112,26 +112,26 @@ function loadProjectBuilds(projectID)
|
||||
<th class='rowhead'><?php echo $lang->bug->lblProductAndModule;?></th>
|
||||
<td class='a-left'>
|
||||
<?php echo html::select('product', $products, $productID, "onchange=loadAll(this.value); class='select-2'");?>
|
||||
<span id='moduleIdBox'><?php echo html::select('module', $moduleOptionMenu, $currentModuleID, 'class=select-3');?></span>
|
||||
<span id='moduleIdBox'><?php echo html::select('module', $moduleOptionMenu, $moduleID, 'class=select-3');?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->bug->lblProjectAndTask;?></th>
|
||||
<td class='a-left'>
|
||||
<span id='projectIdBox'><?php echo html::select('project', $projects, '', 'onchange=loadProjectRelated(this.value)');?></span>
|
||||
<span id='projectIdBox'><?php echo html::select('project', $projects, $projectID, 'onchange=loadProjectRelated(this.value)');?></span>
|
||||
<span id='taskIdBox'></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->bug->lblStory;?></th>
|
||||
<td class='a-left'>
|
||||
<span id='storyIdBox'><?php echo html::select('story', $stories);?></span>
|
||||
<span id='storyIdBox'><?php echo html::select('story', $stories, $storyID);?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->bug->openedBuild;?></th>
|
||||
<td class='a-left'>
|
||||
<span id='buildBox'><?php echo html::select('openedBuild', $builds);?></span>
|
||||
<span id='buildBox'><?php echo html::select('openedBuild', $builds, $buildID);?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -158,11 +158,11 @@ function loadProjectBuilds(projectID)
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->bug->title;?></th>
|
||||
<td class='a-left'><input type='text' name='title' class='text-1' /></td>
|
||||
<td class='a-left'><input type='text' name='title' class='text-1' value='<?php echo $title;?>' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->bug->steps;?></th>
|
||||
<td class='a-left'><textarea name='steps' class='area-1' rows='6'></textarea></td>
|
||||
<td class='a-left'><textarea name='steps' class='area-1' rows='6'><?php echo $steps;?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->bug->files;?></th>
|
||||
|
||||
@@ -102,9 +102,10 @@ class testtask extends control
|
||||
$this->view->position[] = $this->lang->testtask->view;
|
||||
|
||||
/* 赋值。*/
|
||||
$this->view->task = $task;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noclosed');
|
||||
$this->view->runs = $this->testtask->getRuns($taskID);
|
||||
$this->view->productID = $productID;
|
||||
$this->view->task = $task;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noclosed');
|
||||
$this->view->runs = $this->testtask->getRuns($taskID);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ function checkall(checker)
|
||||
<?php
|
||||
common::printLink('testtask', 'runcase', "id=$run->id", $lang->testtask->runCase, '', 'class="iframe"');
|
||||
common::printLink('testtask', 'results', "id=$run->id", $lang->testtask->results, '', 'class="iframe"');
|
||||
//common::printLink('bug', 'create', "id=$run->id", $lang->testtask->createBug);
|
||||
common::printLink('bug', 'create', "product=$productID&extra=projectID=$task->project,buildID=$task->build,runID=$run->id", $lang->testtask->createBug);
|
||||
common::printLink('testtask', 'unlinkcase', "id=$run->id", $lang->testtask->unlinkCase, 'hiddenwin');
|
||||
?>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user