From 45be42a13ba5b40e7b6e81238dd08d3b93d9c041 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 14 Aug 2014 06:08:48 +0000 Subject: [PATCH] * finish task #1934. --- module/bug/control.php | 2 +- module/bug/model.php | 6 ++- module/common/control.php | 1 - module/testcase/control.php | 36 +++++++++++++++++ module/testcase/lang/en.php | 1 + module/testcase/lang/zh-cn.php | 1 + module/testcase/view/browse.html.php | 2 +- module/testcase/view/createbug.html.php | 53 +++++++++++++++++++++++++ module/testcase/view/view.html.php | 2 +- module/testtask/model.php | 1 + module/testtask/view/cases.html.php | 2 +- 11 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 module/testcase/view/createbug.html.php diff --git a/module/bug/control.php b/module/bug/control.php index 0fa39b530c..6958859aa7 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -214,7 +214,7 @@ class bug extends control if(empty($this->products)) $this->locate($this->createLink('product', 'create')); $this->app->loadLang('release'); - if(!empty($_POST)) + if(!empty($_POST) and !isset($_POST['stepIDList'])) { $response['result'] = 'success'; $response['message'] = ''; diff --git a/module/bug/model.php b/module/bug/model.php index 4ff8d00aac..8bacca4ece 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -724,6 +724,7 @@ class bugModel extends model { $title = ''; $bugSteps = ''; + $steps = $this->post->stepIDList; $result = $this->dao->findById($resultID)->from(TABLE_TESTRESULT)->fetch(); if($caseID > 0) @@ -749,13 +750,15 @@ class bugModel extends model { foreach($caseSteps as $key => $step) { + if(!in_array($step->id, $steps)) continue; $bugSteps .= ($key + 1) . '. ' . $step->desc . "
"; } $bugSteps .= $this->lang->bug->tplResult; foreach($caseSteps as $key => $step) { - if(!$stepResults[$step->id]['real']) continue; + if(empty($stepResults[$step->id]['real'])) continue; + if(!in_array($step->id, $steps)) continue; $bugSteps .= ($key + 1) . '. ' . $stepResults[$step->id]['real'] . "
"; } @@ -763,6 +766,7 @@ class bugModel extends model foreach($caseSteps as $key => $step) { if(!$step->expect) continue; + if(!in_array($step->id, $steps)) continue; $bugSteps .= ($key + 1) . '. ' . $step->expect . "
"; } diff --git a/module/common/control.php b/module/common/control.php index af47345f04..43a485199d 100644 --- a/module/common/control.php +++ b/module/common/control.php @@ -259,7 +259,6 @@ class common extends control } /* Set module and method, then create link to it. */ - if(strtolower($module) == 'testcase' and strtolower($method) == 'createbug') ($module = 'bug') and ($method = 'create'); if(strtolower($module) == 'story' and strtolower($method) == 'createcase') ($module = 'testcase') and ($method = 'create'); if(strtolower($module) == 'bug' and strtolower($method) == 'tostory') ($module = 'story') and ($method = 'create'); if(strtolower($module) == 'bug' and strtolower($method) == 'createcase') ($module = 'testcase') and ($method = 'create'); diff --git a/module/testcase/control.php b/module/testcase/control.php index 35e1822f93..4a2a4cdb07 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -379,6 +379,42 @@ class testcase extends control $this->display(); } + /** + * Create bug. + * + * @param int $productID + * @param string $extras + * @access public + * @return void + */ + public function createBug($productID, $extras = '') + { + parse_str(str_replace(array(',', ' '), array('&', ''), $extras)); + + $this->loadModel('testtask'); + $case = ''; + if($runID) + { + $case = $this->testtask->getRunById($runID)->case; + $results = $this->testtask->getResults($runID); + } + elseif($caseID) + { + $case = $this->testcase->getById($caseID); + $results = $this->testtask->getResults(0, $caseID); + } + + if(!$case) die(js::error($this->lang->notFound) . js::locate('back', 'parent')); + if(empty($case->steps)) die(js::locate($this->createLink('bug', 'create', "product=$productID&extras=$extras"))); + + $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->createBug; + $this->view->case = $case; + $this->view->result = reset($results); + $this->view->extras = $extras; + $this->view->productID = $productID; + $this->display(); + } + /** * View a test case. * diff --git a/module/testcase/lang/en.php b/module/testcase/lang/en.php index f9bad8cf0f..48d38f5faa 100644 --- a/module/testcase/lang/en.php +++ b/module/testcase/lang/en.php @@ -45,6 +45,7 @@ $lang->testcase->allProduct = 'All product'; $lang->testcase->fromBug = 'From bug'; $lang->testcase->toBug = 'To bug'; $lang->testcase->changed = 'Changed'; +$lang->testcase->createBug = 'Create bug'; $lang->case = $lang->testcase; // For dao checking using. Because 'case' is a php keywords, so the module name is testcase, table name is still case. $lang->testcase->stepID = 'ID'; diff --git a/module/testcase/lang/zh-cn.php b/module/testcase/lang/zh-cn.php index 56e92dba67..37a0834bb9 100644 --- a/module/testcase/lang/zh-cn.php +++ b/module/testcase/lang/zh-cn.php @@ -45,6 +45,7 @@ $lang->testcase->allProduct = '所有产品'; $lang->testcase->fromBug = '来源Bug'; $lang->testcase->toBug = '生成Bug'; $lang->testcase->changed = '用例变更'; +$lang->testcase->createBug = '创建Bug'; $lang->case = $lang->testcase; // 用于DAO检查时使用。因为case是系统关键字,所以无法定义该模块为case,只能使用testcase,但表还是使用的case。 $lang->testcase->stepID = '编号'; diff --git a/module/testcase/view/browse.html.php b/module/testcase/view/browse.html.php index 7fa8df6b48..67949a6e1e 100644 --- a/module/testcase/view/browse.html.php +++ b/module/testcase/view/browse.html.php @@ -89,7 +89,7 @@ js::set('confirmDelete', $lang->testcase->confirmDelete); echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"caseList\",confirmDelete)", '', '', "title='{$lang->testcase->delete}' class='btn-icon'"); } - common::printIcon('testcase', 'createBug', "product=$case->product&extra=caseID=$case->id,version=$case->version,runID=", $case, 'list', 'bug'); + common::printIcon('testcase', 'createBug', "product=$case->product&extra=caseID=$case->id,version=$case->version,runID=", $case, 'list', 'bug', '', 'iframe'); ?> diff --git a/module/testcase/view/createbug.html.php b/module/testcase/view/createbug.html.php new file mode 100644 index 0000000000..84cdbef581 --- /dev/null +++ b/module/testcase/view/createbug.html.php @@ -0,0 +1,53 @@ + + * @package testcase + * @version $Id$ + * @link http://www.zentao.net + */ +?> + +
' target='_parent' method='post'> + + + + + + + + + + + + + stepResults as $stepID => $stepResult):?> + + + + + + + + + + + + + + + +
testcase->stepID;?>testcase->stepDesc;?>testcase->stepExpect;?>testcase->result;?>testcase->real;?>
+ + + text-center'>testcase->resultList, zget($stepResult, 'result'));?>
+ " . html::selectButton() . ''; + echo html::submitButton(); + ?> +
+
+ diff --git a/module/testcase/view/view.html.php b/module/testcase/view/view.html.php index 0b65fd788e..b5e6614653 100644 --- a/module/testcase/view/view.html.php +++ b/module/testcase/view/view.html.php @@ -46,7 +46,7 @@ common::printIcon('testtask', 'runCase', "runID=0&caseID=$case->id&version=$case->currentVersion", '', 'button', '', '', 'runCase'); common::printIcon('testtask', 'results', "runID=0&caseID=$case->id&version=$case->version", '', 'button', '', '', 'results'); - if($case->lastRunResult == 'fail') common::printIcon('testcase', 'createBug', "product=$case->product&extra=caseID=$case->id,version=$case->version,runID=", '', 'button', 'bug'); + if($case->lastRunResult == 'fail') common::printIcon('testcase', 'createBug', "product=$case->product&extra=caseID=$case->id,version=$case->version,runID=", '', 'button', 'bug', '', 'iframe'); echo ''; echo "
"; diff --git a/module/testtask/model.php b/module/testtask/model.php index 894efb6d1e..35f410dfc0 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -337,6 +337,7 @@ class testtaskModel extends model ->setForce('stepResults', serialize($stepResults)) ->add('lastRunner', $this->app->user->account) ->add('date', $now) + ->skipSpecial('stepResults') ->remove('steps,reals,result') ->get(); $this->dao->insert(TABLE_TESTRESULT)->data($result)->autoCheck()->exec(); diff --git a/module/testtask/view/cases.html.php b/module/testtask/view/cases.html.php index a0e224b496..854d3c8809 100644 --- a/module/testtask/view/cases.html.php +++ b/module/testtask/view/cases.html.php @@ -82,7 +82,7 @@ var moduleID = ''; echo html::a("javascript:ajaxDelete(\"$unlinkURL\",\"caseList\",confirmUnlink)", '', '', "title='{$lang->testtask->unlinkCase}' class='btn-icon'"); } - common::printIcon('testcase', 'createBug', "product=$productID&extra=projectID=$task->project,buildID=$task->build,caseID=$run->case,version=$run->version,runID=$run->id,testtask=$taskID", $run, 'list', 'bug'); + common::printIcon('testcase', 'createBug', "product=$productID&extra=projectID=$task->project,buildID=$task->build,caseID=$run->case,version=$run->version,runID=$run->id,testtask=$taskID", $run, 'list', 'bug', '', 'iframe'); ?>