From 9d3d6d278a9596d663457f79c698c876b878f5fd Mon Sep 17 00:00:00 2001 From: wangyidong Date: Tue, 10 Jan 2017 16:15:18 +0800 Subject: [PATCH 1/5] * adjust for export with branch. --- module/testcase/config.php | 2 +- module/testcase/control.php | 35 ++++++++++++++---------- module/testcase/model.php | 8 ++++-- module/testcase/view/showimport.html.php | 22 +++++++++------ 4 files changed, 42 insertions(+), 25 deletions(-) diff --git a/module/testcase/config.php b/module/testcase/config.php index 13dad92b5c..666f2a89d6 100644 --- a/module/testcase/config.php +++ b/module/testcase/config.php @@ -16,7 +16,7 @@ $config->testcase->export = new stdclass(); $config->testcase->export->listFields = array('type', 'stage', 'pri', 'status'); $config->testcase->exportFields = ' - id, product, module, story, + id, product, branch, module, story, title, precondition, stepDesc, stepExpect, keywords, pri, type, stage, status, lastRunResult, openedBy, openedDate, lastEditedBy, lastEditedDate, version,linkCase'; diff --git a/module/testcase/control.php b/module/testcase/control.php index f19224f051..829a1a4ca4 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -836,17 +836,22 @@ class testcase extends control */ public function export($productID, $orderBy, $taskID = 0) { + $product = $this->loadModel('product')->getById($productID); + if($product->type != 'normal') $this->lang->testcase->branch = $this->lang->product->branchName[$product->type]; if($_POST) { $caseLang = $this->lang->testcase; $caseConfig = $this->config->testcase; /* Create field lists. */ - $fields = $this->post->exportFields ? $this->post->exportFields : explode(',', $caseConfig->exportFields); + $fields = $this->post->exportFields ? $this->post->exportFields : explode(',', $caseConfig->exportFields); foreach($fields as $key => $fieldName) { $fieldName = trim($fieldName); - $fields[$fieldName] = isset($caseLang->$fieldName) ? $caseLang->$fieldName : $fieldName; + if(!($product->type == 'normal' and $fieldName == 'branch')) + { + $fields[$fieldName] = isset($caseLang->$fieldName) ? $caseLang->$fieldName : $fieldName; + } unset($fields[$key]); } @@ -884,6 +889,7 @@ class testcase extends control /* Get users, products and projects. */ $users = $this->loadModel('user')->getPairs('noletter'); $products = $this->loadModel('product')->getPairs('nocode'); + $branches = $this->loadModel('branch')->getPairs($productID); /* Get related objects id lists. */ $relatedModuleIdList = array(); @@ -938,6 +944,7 @@ class testcase extends control /* fill some field with useful value. */ if(isset($products[$case->product])) $case->product = $products[$case->product] . "(#$case->product)"; + if(isset($branches[$case->branch])) $case->branch = $branches[$case->branch] . "(#$case->branch)"; if(isset($relatedModules[$case->module])) $case->module = $relatedModules[$case->module] . "(#$case->module)"; if(isset($relatedStories[$case->story])) $case->story = $relatedStories[$case->story] . "(#$case->story)"; @@ -990,6 +997,9 @@ class testcase extends control { if($_POST) { + $product = $this->loadModel('product')->getById($productID); + + if($product->type != 'normal') $fields['branch'] = $this->lang->product->branchName[$product->type]; $fields['module'] = $this->lang->testcase->module; $fields['title'] = $this->lang->testcase->title; $fields['stepDesc'] = $this->lang->testcase->stepDesc; @@ -1005,6 +1015,10 @@ class testcase extends control $fields['typeValue'] = $this->lang->testcase->lblTypeValue; $fields['stageValue'] = $this->lang->testcase->lblStageValue; $fields['statusValue'] = $this->lang->testcase->lblStatusValue; + if($product->type != 'normal') $fields['branchValue'] = $this->lang->product->branchName[$product->type]; + + $branches = $this->loadModel('branch')->getPairs($productID); + foreach($branches as $branchID => $branchName) $branches[$branchID] = $branchName . "(#$branchID)"; $modules = $this->loadModel('tree')->getOptionMenu($productID, 'case'); $rows = array(); @@ -1020,6 +1034,7 @@ class testcase extends control $row->typeValue = join("\n", $this->lang->testcase->typeList); $row->stageValue = join("\n", $this->lang->testcase->stageList); $row->statusValue = join("\n", $this->lang->testcase->statusList); + if($product->type != 'normal') $row->branchValue = join("\n", $branches); } $rows[] = $row; } @@ -1053,7 +1068,7 @@ class testcase extends control $fileName = $this->file->savePath . $file['pathname']; $rows = $this->file->parseCSV($fileName); - $fields = $this->testcase->getImportFields(); + $fields = $this->testcase->getImportFields($productID); $fields = array_flip($fields); $header = array(); foreach($rows[0] as $i => $rowValue) @@ -1123,7 +1138,7 @@ class testcase extends control $caseConfig = $this->config->testcase; $modules = $this->loadModel('tree')->getOptionMenu($productID, 'case', 0, $branch); $stories = $this->loadModel('story')->getProductStoryPairs($productID, $branch); - $fields = $this->testcase->getImportFields(); + $fields = $this->testcase->getImportFields($productID); $fields = array_flip($fields); $rows = $this->loadModel('file')->parseCSV($file); @@ -1151,16 +1166,7 @@ class testcase extends control { if(!isset($data[$key])) continue; $cellValue = $data[$key]; - if($field == 'story') - { - $case->$field = 0; - if(strrpos($cellValue, '(#') !== false) - { - $id = trim(substr($cellValue, strrpos($cellValue,'(#') + 2), ')'); - $case->$field = $id; - } - } - elseif($field == 'module') + if($field == 'story' or $field == 'module' or $field == 'branch') { $case->$field = 0; if(strrpos($cellValue, '(#') !== false) @@ -1248,6 +1254,7 @@ class testcase extends control $this->view->caseData = $caseData; $this->view->stepData = $stepData; $this->view->productID = $productID; + $this->view->branches = $this->loadModel('branch')->getPairs($productID); $this->view->branch = $branch; $this->view->product = $this->products[$productID]; $this->display(); diff --git a/module/testcase/model.php b/module/testcase/model.php index 862855b072..1c3d729c41 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -797,6 +797,7 @@ class testcaseModel extends model $caseData = new stdclass(); $caseData->product = $product; + $caseData->branch = isset($data->branch[$key]) ? $data->branch[$key] : $branch; $caseData->module = $data->module[$key]; $caseData->story = (int)$data->story[$key]; $caseData->title = $data->title[$key]; @@ -901,7 +902,7 @@ class testcaseModel extends model $caseData->version = 1; $caseData->openedBy = $this->app->user->account; $caseData->openedDate = $now; - $caseData->branch = $branch; + $caseData->branch = isset($data->branch[$key]) ? $data->branch[$key] : $branch; $this->dao->insert(TABLE_CASE)->data($caseData)->autoCheck()->exec(); if(!dao::isError()) @@ -933,8 +934,11 @@ class testcaseModel extends model * @access public * @return array */ - public function getImportFields() + public function getImportFields($productID = 0) { + $product = $this->loadModel('product')->getById($productID); + if($product->type != 'normal') $this->lang->testcase->branch = $this->lang->product->branchName[$product->type]; + $caseLang = $this->lang->testcase; $caseConfig = $this->config->testcase; $fields = explode(',', $caseConfig->exportFields); diff --git a/module/testcase/view/showimport.html.php b/module/testcase/view/showimport.html.php index 0272e87649..274cf15492 100644 --- a/module/testcase/view/showimport.html.php +++ b/module/testcase/view/showimport.html.php @@ -6,10 +6,13 @@ - + - - + + + + + @@ -46,11 +49,14 @@ ?> - - - - - + + + + + + + + From 86997cd179eabf31ea3e221bacf957b793ef3c2c Mon Sep 17 00:00:00 2001 From: chenfeiCF Date: Wed, 11 Jan 2017 13:38:49 +0800 Subject: [PATCH 2/5] * finish task #2870. --- module/testcase/lang/en.php | 2 +- module/testcase/lang/zh-cn.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/module/testcase/lang/en.php b/module/testcase/lang/en.php index eaf73ecaad..38d0351cbd 100644 --- a/module/testcase/lang/en.php +++ b/module/testcase/lang/en.php @@ -134,7 +134,7 @@ $lang->testcase->statusList['normal'] = 'Normal'; $lang->testcase->statusList['blocked'] = 'Blocked'; $lang->testcase->statusList['investigate'] = 'Investigating'; -$lang->testcase->resultList['n/a'] = 'N/A'; +$lang->testcase->resultList['n/a'] = 'Ignore'; $lang->testcase->resultList['pass'] = 'Pass'; $lang->testcase->resultList['fail'] = 'Fail'; $lang->testcase->resultList['blocked'] = 'Blocked'; diff --git a/module/testcase/lang/zh-cn.php b/module/testcase/lang/zh-cn.php index b8c28688fb..21ea51b77a 100644 --- a/module/testcase/lang/zh-cn.php +++ b/module/testcase/lang/zh-cn.php @@ -134,7 +134,7 @@ $lang->testcase->statusList['normal'] = '正常'; $lang->testcase->statusList['blocked'] = '被阻塞'; $lang->testcase->statusList['investigate'] = '研究中'; -$lang->testcase->resultList['n/a'] = 'N/A'; +$lang->testcase->resultList['n/a'] = '忽略'; $lang->testcase->resultList['pass'] = '通过'; $lang->testcase->resultList['fail'] = '失败'; $lang->testcase->resultList['blocked'] = '阻塞'; From 29260391221d2e4fe146e3796dd631a8375d0726 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 11 Jan 2017 14:12:00 +0800 Subject: [PATCH 3/5] * finish task #2862. --- module/bug/model.php | 20 ++++++++++++ module/common/model.php | 3 +- module/datatable/model.php | 12 +++---- module/my/control.php | 5 --- module/project/control.php | 5 --- module/story/config.php | 3 ++ module/task/config.php | 1 + module/testcase/config.php | 15 ++++++++- module/testcase/control.php | 18 +++++++++++ module/testcase/css/bugs.css | 3 ++ module/testcase/lang/zh-cn.php | 3 ++ module/testcase/model.php | 37 ++++++++++++++++++++++ module/testcase/view/browse.html.php | 2 +- module/testcase/view/browsedata.html.php | 27 +++++++++------- module/testcase/view/bugs.html.php | 40 ++++++++++++++++++++++++ module/testcase/view/view.html.php | 2 +- module/testtask/config.php | 2 +- module/testtask/control.php | 33 ++++++++++--------- module/testtask/model.php | 20 +++++++----- module/testtask/view/cases.html.php | 2 +- module/testtask/view/casesdata.html.php | 23 ++++++++------ module/testtask/view/runcase.html.php | 2 +- 22 files changed, 208 insertions(+), 70 deletions(-) create mode 100644 module/testcase/css/bugs.css create mode 100644 module/testcase/view/bugs.html.php diff --git a/module/bug/model.php b/module/bug/model.php index 7666ca712c..a56d157b44 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1230,6 +1230,26 @@ class bugModel extends model ->fetchAll('id'); } + /** + * Get case bugs. + * + * @param int $runID + * @param int $caseID + * @param int $version + * @access public + * @return void + */ + public function getCaseBugs($runID, $caseID = 0, $version = 0) + { + return $this->dao->select('*')->from(TABLE_BUG) + ->where('1=1') + ->beginIF($runID)->andWhere('`result`')->eq($runID)->fi() + ->beginIF($runID == 0 and $caseID)->andWhere('`case`')->eq($caseID)->fi() + ->beginIF($version)->andWhere('`caseVersion`')->eq($version)->fi() + ->andWhere('deleted')->eq(0) + ->fetchAll('id'); + } + /** * Get counts of some stories' bugs. * diff --git a/module/common/model.php b/module/common/model.php index e696e88e7c..b5b21ed7a6 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -934,7 +934,6 @@ class commonModel extends model * Get the previous and next object. * * @param string $type story|task|bug|case - * @param string $objectIDs * @param string $objectID * @access public * @return void @@ -949,7 +948,7 @@ class commonModel extends model $existObject = $type . 'PreAndNext'; if(isset($_SESSION[$existObject]) and $_SESSION[$existObject]['objectID'] == $objectID) return $_SESSION[$existObject]['preAndNextObject']; - /* Get objectIDs. */ + /* Get objectIDList. */ $table = $this->config->objectTables[$type]; $queryCondition = $type . 'QueryCondition'; $typeOnlyCondition = $type . 'OnlyCondition'; diff --git a/module/datatable/model.php b/module/datatable/model.php index 9cb2876a58..571da4d9a1 100644 --- a/module/datatable/model.php +++ b/module/datatable/model.php @@ -68,6 +68,7 @@ class datatableModel extends model $set->width = $fieldList[$id]['width']; $set->fixed = $fieldList[$id]['fixed']; $set->title = $fieldList[$id]['title']; + $set->sort = isset($fieldList[$id]['sort']) ? $fieldList[$id]['sort'] : 'yes'; $setting[$key] = $set; } } @@ -81,6 +82,7 @@ class datatableModel extends model continue; } $set->title = $fieldList[$set->id]['title']; + $set->sort = isset($fieldList[$set->id]['sort']) ? $fieldList[$set->id]['sort'] : 'yes'; } } @@ -123,15 +125,9 @@ class datatableModel extends model { echo $this->lang->actions; } - elseif($id == 'progess') + elseif(isset($col->sort) and $col->sort == 'no') { - $this->app->loadLang('task'); - echo $this->lang->task->progess; - } - elseif($id == 'taskCount' or $id == 'bugCount' or $id == 'caseCount') - { - $this->app->loadLang('story'); - echo $this->lang->story->$id; + echo $col->title; } else { diff --git a/module/my/control.php b/module/my/control.php index daef531402..7ae9fa5ddd 100644 --- a/module/my/control.php +++ b/module/my/control.php @@ -188,11 +188,6 @@ class my extends control $sort = $this->loadModel('common')->appendOrder($orderBy); $bugs = $this->loadModel('bug')->getUserBugs($this->app->user->account, $type, $sort, 0, $pager); - /* Save bugIDs session for get the pre and next bug. */ - $bugIDs = ''; - foreach($bugs as $bug) $bugIDs .= ',' . $bug->id; - $this->session->set('bugIDs', $bugIDs . ','); - /* assign. */ $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->bug; $this->view->position[] = $this->lang->my->bug; diff --git a/module/project/control.php b/module/project/control.php index cbfd57a1df..797eff54e3 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -557,11 +557,6 @@ class project extends control $storyTasks = $this->task->getStoryTaskCounts(array_keys($stories), $projectID); $users = $this->user->getPairs('noletter'); - /* Save storyIDs session for get the pre and next story. */ - $storyIDs = ''; - foreach($stories as $story) $storyIDs .= ',' . $story->id; - $this->session->set('storyIDs', $storyIDs . ','); - /* Get project's product. */ $productID = 0; $productPairs = $this->loadModel('product')->getProductsByProject($projectID); diff --git a/module/story/config.php b/module/story/config.php index 8859b99fa8..200f77e38d 100644 --- a/module/story/config.php +++ b/module/story/config.php @@ -93,16 +93,19 @@ $config->story->datatable->fieldList['taskCount']['title'] = 'taskCount'; $config->story->datatable->fieldList['taskCount']['fixed'] = 'no'; $config->story->datatable->fieldList['taskCount']['width'] = '90'; $config->story->datatable->fieldList['taskCount']['required'] = 'no'; +$config->story->datatable->fieldList['taskCount']['sort'] = 'no'; $config->story->datatable->fieldList['bugCount']['title'] = 'bugCount'; $config->story->datatable->fieldList['bugCount']['fixed'] = 'no'; $config->story->datatable->fieldList['bugCount']['width'] = '90'; $config->story->datatable->fieldList['bugCount']['required'] = 'no'; +$config->story->datatable->fieldList['bugCount']['sort'] = 'no'; $config->story->datatable->fieldList['caseCount']['title'] = 'caseCount'; $config->story->datatable->fieldList['caseCount']['fixed'] = 'no'; $config->story->datatable->fieldList['caseCount']['width'] = '90'; $config->story->datatable->fieldList['caseCount']['required'] = 'no'; +$config->story->datatable->fieldList['caseCount']['sort'] = 'no'; $config->story->datatable->fieldList['openedBy']['title'] = 'openedByAB'; $config->story->datatable->fieldList['openedBy']['fixed'] = 'no'; diff --git a/module/task/config.php b/module/task/config.php index 0740ca1c91..0b88e4d80d 100644 --- a/module/task/config.php +++ b/module/task/config.php @@ -93,6 +93,7 @@ $config->task->datatable->fieldList['progess']['title'] = 'progess'; $config->task->datatable->fieldList['progess']['fixed'] = 'no'; $config->task->datatable->fieldList['progess']['width'] = '40'; $config->task->datatable->fieldList['progess']['required'] = 'no'; +$config->task->datatable->fieldList['progess']['sort'] = 'no'; $config->task->datatable->fieldList['deadline']['title'] = 'deadlineAB'; $config->task->datatable->fieldList['deadline']['fixed'] = 'no'; diff --git a/module/testcase/config.php b/module/testcase/config.php index 666f2a89d6..9ca5cb19d2 100644 --- a/module/testcase/config.php +++ b/module/testcase/config.php @@ -66,7 +66,7 @@ $config->testcase->search['params']['openedDate'] = array('operator' => '=', $config->testcase->search['params']['lastEditedDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); $config->testcase->datatable = new stdclass(); -$config->testcase->datatable->defaultField = array('id', 'pri', 'title', 'type', 'openedBy', 'lastRunner', 'lastRunDate', 'lastRunResult', 'status', 'actions'); +$config->testcase->datatable->defaultField = array('id', 'pri', 'title', 'type', 'openedBy', 'lastRunner', 'lastRunDate', 'lastRunResult', 'status', 'bugs', 'results', 'actions'); $config->testcase->datatable->fieldList['id']['title'] = 'idAB'; $config->testcase->datatable->fieldList['id']['fixed'] = 'left'; @@ -132,8 +132,21 @@ $config->testcase->datatable->fieldList['actions']['title'] = 'actions'; $config->testcase->datatable->fieldList['actions']['fixed'] = 'right'; $config->testcase->datatable->fieldList['actions']['width'] = '140'; $config->testcase->datatable->fieldList['actions']['required'] = 'yes'; +$config->testcase->datatable->fieldList['actions']['sort'] = 'no'; $config->testcase->datatable->fieldList['branch']['title'] = 'branch'; $config->testcase->datatable->fieldList['branch']['fixed'] = 'left'; $config->testcase->datatable->fieldList['branch']['width'] = '100'; $config->testcase->datatable->fieldList['branch']['required'] = 'no'; + +$config->testcase->datatable->fieldList['bugs']['title'] = 'bugs'; +$config->testcase->datatable->fieldList['bugs']['fixed'] = 'no'; +$config->testcase->datatable->fieldList['bugs']['width'] = '80'; +$config->testcase->datatable->fieldList['bugs']['required'] = 'no'; +$config->testcase->datatable->fieldList['bugs']['sort'] = 'no'; + +$config->testcase->datatable->fieldList['results']['title'] = 'results'; +$config->testcase->datatable->fieldList['results']['fixed'] = 'no'; +$config->testcase->datatable->fieldList['results']['width'] = '80'; +$config->testcase->datatable->fieldList['results']['required'] = 'no'; +$config->testcase->datatable->fieldList['results']['sort'] = 'no'; diff --git a/module/testcase/control.php b/module/testcase/control.php index 829a1a4ca4..89fda33863 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -101,6 +101,7 @@ class testcase extends control /* Process case for check story changed. */ $cases = $this->loadModel('story')->checkNeedConfirm($cases); + $cases = $this->testcase->appendBugAndResults($cases); /* Build the search form. */ $actionURL = $this->createLink('testcase', 'browse', "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID"); @@ -1259,4 +1260,21 @@ class testcase extends control $this->view->product = $this->products[$productID]; $this->display(); } + + /** + * Case bugs. + * + * @param int $runID + * @param int $caseID + * @param int $version + * @access public + * @return void + */ + public function bugs($runID, $caseID = 0, $version = 0) + { + $this->view->title = $this->lang->testcase->bugs; + $this->view->bugs = $this->loadModel('bug')->getCaseBugs($runID, $caseID, $version); + $this->view->users = $this->loadModel('user')->getPairs('noletter'); + $this->display(); + } } diff --git a/module/testcase/css/bugs.css b/module/testcase/css/bugs.css new file mode 100644 index 0000000000..dfd311f034 --- /dev/null +++ b/module/testcase/css/bugs.css @@ -0,0 +1,3 @@ +body{background:white} +.bugsList {padding:10px;} +.bugsList .table{border: 1px solid #ddd;} diff --git a/module/testcase/lang/zh-cn.php b/module/testcase/lang/zh-cn.php index b8c28688fb..f14fd35e74 100644 --- a/module/testcase/lang/zh-cn.php +++ b/module/testcase/lang/zh-cn.php @@ -44,6 +44,9 @@ $lang->testcase->allProduct = "所有{$lang->productCommon}"; $lang->testcase->fromBug = '来源Bug'; $lang->testcase->toBug = '生成Bug'; $lang->testcase->changed = '用例变更'; +$lang->testcase->bugs = '产生Bug数'; +$lang->testcase->bugsAB = 'B'; +$lang->testcase->results = '执行数'; $lang->testcase->createBug = '转Bug'; $lang->case = $lang->testcase; // 用于DAO检查时使用。因为case是系统关键字,所以无法定义该模块为case,只能使用testcase,但表还是使用的case。 diff --git a/module/testcase/model.php b/module/testcase/model.php index 1c3d729c41..602713195a 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -1052,6 +1052,12 @@ class testcaseModel extends model case 'lastRunResult': if($case->lastRunResult) echo $this->lang->testcase->resultList[$case->lastRunResult]; break; + case 'bugs': + echo (common::hasPriv('testcase', 'bugs') and $case->bugs) ? html::a(helper::createLink('testcase', 'bugs', "runID=0&caseID={$case->id}"), $case->bugs, '', "class='iframe'") : $case->bugs; + break; + case 'results': + echo (common::hasPriv('testtask', 'results') and $case->results) ? html::a(helper::createLink('testtask', 'results', "runID=0&caseID={$case->id}"), $case->results, '', "class='iframe'") : $case->results; + break; case 'actions': common::printIcon('testtask', 'runCase', "runID=0&caseID=$case->id&version=$case->version", '', 'list', 'play', '', 'runCase iframe'); common::printIcon('testtask', 'results', "runID=0&caseID=$case->id", '', 'list', '', '', 'results iframe'); @@ -1070,4 +1076,35 @@ class testcaseModel extends model echo ''; } } + + /** + * Append bugs and results. + * + * @param array $cases + * @access public + * @return array + */ + public function appendBugAndResults($cases, $type = 'case') + { + $caseIdList = array_keys($cases); + if($type == 'case') + { + $caseBugs = $this->dao->select('count(*) as count, `case`')->from(TABLE_BUG)->where('`case`')->in($caseIdList)->andWhere('deleted')->eq(0)->groupBy('`case`')->fetchPairs('case', 'count'); + $results = $this->dao->select('count(*) as count, `case`')->from(TABLE_TESTRESULT)->where('`case`')->in($caseIdList)->groupBy('`case`')->fetchPairs('case', 'count'); + } + else + { + $caseBugs = $this->dao->select('count(*) as count, `case`')->from(TABLE_BUG)->where('`result`')->in($caseIdList)->andWhere('deleted')->eq(0)->groupBy('`case`')->fetchPairs('case', 'count'); + $results = $this->dao->select('count(*) as count, `case`')->from(TABLE_TESTRESULT)->where('`run`')->in($caseIdList)->groupBy('`run`')->fetchPairs('case', 'count'); + } + + foreach($cases as $case) + { + $caseID = $type == 'case' ? $case->id : $case->case; + $case->bugs = isset($caseBugs[$caseID]) ? $caseBugs[$caseID] : 0; + $case->results = isset($results[$caseID]) ? $results[$caseID] : 0; + } + + return $cases; + } } diff --git a/module/testcase/view/browse.html.php b/module/testcase/view/browse.html.php index 3dda295fca..7306711d06 100644 --- a/module/testcase/view/browse.html.php +++ b/module/testcase/view/browse.html.php @@ -47,7 +47,7 @@ js::set('batchDelete', $lang->testcase->confirmBatchDelete); ?> - +
testcase->id?>testcase->id?> testcase->title?>testcase->module?>testcase->story?>testcase->branch?>testcase->module?>testcase->story?> testcase->pri?> testcase->type?> testcase->status?> title, "class='form-control' style='margin-top:2px'")?>module) ? $case->module : (!empty($case->id) ? $cases[$case->id]->module : ''), "class='form-control chosen'")?>story) ? $case->story : (!empty($case->id) ? $cases[$case->id]->story : ''), "class='form-control chosen'")?>testcase->priList, !empty($case->pri) ? $case->pri : (!empty($case->id) ? $cases[$case->id]->pri : ''), "class='form-control'")?>testcase->typeList, !empty($case->type) ? $case->type : (!empty($case->id) ? $cases[$case->id]->type : ''), "class='form-control'")?>testcase->statusList, !empty($case->status) ? $case->status : (!empty($case->id) ? $cases[$case->id]->status : 'normal'), "class='form-control'")?>branch) and $case->branch !== '') ? $case->branch : (!empty($case->id) ? $cases[$case->id]->branch : $branch), "class='form-control chosen'")?>module) ? $case->module : (!empty($case->id) ? $cases[$case->id]->module : ''), "class='form-control chosen'")?>story) ? $case->story : (!empty($case->id) ? $cases[$case->id]->story : ''), "class='form-control chosen'")?>testcase->priList, isset($case->pri) ? $case->pri : (!empty($case->id) ? $cases[$case->id]->pri : ''), "class='form-control'")?>testcase->typeList, isset($case->type) ? $case->type : (!empty($case->id) ? $cases[$case->id]->type : ''), "class='form-control'")?>testcase->statusList, isset($case->status) ? $case->status : (!empty($case->id) ? $cases[$case->id]->status : 'normal'), "class='form-control'")?> testcase->stageList, !empty($case->stage) ? $case->stage : (!empty($case->id) ? $cases[$case->id]->stage : ''), "multiple='multiple' class='form-control chosen'")?> keywords) ? $case->keywords : "", "class='form-control'")?> precondition) ? htmlspecialchars($case->precondition) : "", "class='form-control'")?>
diff --git a/module/testcase/view/browsedata.html.php b/module/testcase/view/browsedata.html.php index 3d36b06b6c..76b31192d5 100644 --- a/module/testcase/view/browsedata.html.php +++ b/module/testcase/view/browsedata.html.php @@ -10,22 +10,25 @@ * @link http://www.zentao.net */ ?> + - - - + + + - - + + - - - - - - + + + + + + + + @@ -68,6 +71,8 @@ } ?> + + - + -
idAB);?> priAB);?> testcase->title);?> idAB);?> priAB);?> testcase->title);?> testcase->story);?>actions;?> testcase->story);?> actions;?> typeAB);?> openedByAB);?> testtask->lastRunAccount);?> testtask->lastRunTime);?> testtask->lastRunResult);?> statusAB);?> typeAB);?> openedByAB);?> testtask->lastRunAccount);?> testtask->lastRunTime);?> testtask->lastRunResult);?> statusAB);?> testcase->bugsAB;?> testcase->results?> actions;?>
bugs) ? html::a(inlink('bugs', "runID=0&caseID={$case->id}"), $case->bugs, '', "class='iframe'") : $case->bugs?>results) ? html::a($this->createLink('testtask', 'results', "runID=0&caseID={$case->id}"), $case->results, '', "class='iframe'") : $case->results?> id&version=$case->version", '', 'list', 'play', '', 'runCase iframe'); diff --git a/module/testcase/view/bugs.html.php b/module/testcase/view/bugs.html.php new file mode 100644 index 0000000000..706ccd7196 --- /dev/null +++ b/module/testcase/view/bugs.html.php @@ -0,0 +1,40 @@ + +
+
+ icons['report']);?> + testcase->bugs;?> +
+
+
+
+ + + + + + + + + + + + + + + $bug):?> + + + + + + + + + + + + +
idAB;?> bug->title;?> priAB;?> bug->type;?>statusAB;?> bug->assignedTo;?> bug->resolvedBy;?> bug->resolution;?>
id;?>title;?>bug->priList, $bug->pri, $bug->pri)?>'>pri == '0' ? '' : zget($lang->bug->priList, $bug->pri, $bug->pri);?>bug->typeList[$bug->type];?>bug->statusList[$bug->status];?>assignedTo, $bug->assignedTo);?>resolvedBy, $bug->resolvedBy);?>bug->resolutionList[$bug->resolution];?>
+
+
+ diff --git a/module/testcase/view/view.html.php b/module/testcase/view/view.html.php index 9b7da76ae1..c82049eb97 100644 --- a/module/testcase/view/view.html.php +++ b/module/testcase/view/view.html.php @@ -239,7 +239,7 @@ toBugs):?>
testcase->toBug;?>testcase->toBug;?> toBugs as $bugID => $bugTitle) diff --git a/module/testtask/config.php b/module/testtask/config.php index 822821a89a..270b424076 100644 --- a/module/testtask/config.php +++ b/module/testtask/config.php @@ -13,4 +13,4 @@ $config->testtask->editor->start = array('id' => 'comment', 'tools' => 'simpleT $config->testtask->editor->close = array('id' => 'report,comment', 'tools' => 'simpleTools'); $config->testtask->datatable = new stdclass(); -$config->testtask->datatable->defaultField = array('id', 'pri', 'title', 'type', 'assignedTo', 'lastRunner', 'lastRunDate', 'lastRunResult', 'status', 'actions'); +$config->testtask->datatable->defaultField = array('id', 'pri', 'title', 'type', 'assignedTo', 'lastRunner', 'lastRunDate', 'lastRunResult', 'status', 'bugs', 'results', 'actions'); diff --git a/module/testtask/control.php b/module/testtask/control.php index 76f59c5b0d..8bc58a64f4 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -252,14 +252,9 @@ class testtask extends control $sort = $this->loadModel('common')->appendOrder($orderBy, 't2.id'); /* Get test cases. */ - $this->view->runs = $this->testtask->getTaskCases($productID, $browseType, $queryID, $moduleID, $sort, $pager, $task); + $runs = $this->testtask->getTaskCases($productID, $browseType, $queryID, $moduleID, $sort, $pager, $task); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false); - /* Save testcaseIDs session for get the pre and next testcase. */ - $testcaseIDs = ''; - foreach($this->view->runs as $run) $testcaseIDs .= ',' . $run->case; - $this->session->set('testcaseIDs', $testcaseIDs . ','); - /* Build the search form. */ $this->loadModel('testcase'); $this->config->testcase->search['module'] = 'testtask'; @@ -270,6 +265,9 @@ class testtask extends control unset($this->config->testcase->search['params']['branch']); $this->loadModel('search')->setSearchParams($this->config->testcase->search); + /* Append bugs and results. */ + $runs = $this->testcase->appendBugAndResults($runs, 'run'); + $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->cases; $this->view->position[] = html::a($this->createLink('testtask', 'browse', "productID=$productID"), $this->products[$productID]); $this->view->position[] = $this->lang->testtask->common; @@ -278,6 +276,7 @@ class testtask extends control $this->view->productID = $productID; $this->view->productName = $this->products[$productID]; $this->view->task = $task; + $this->view->runs = $runs; $this->view->users = $this->loadModel('user')->getPairs('noclosed,qafirst'); $this->view->assignedTos = $this->loadModel('user')->getPairs('noclosed,nodeleted,qafirst'); $this->view->moduleTree = $this->loadModel('tree')->getTreeMenu($productID, $viewType = 'case', $startModuleID = 0, array('treeModel', 'createTestTaskLink'), $extra = $taskID); @@ -686,14 +685,14 @@ class testtask extends control */ public function runCase($runID, $caseID = 0, $version = 0) { - if($caseID) + if($runID) { - $run = new stdclass(); - $run->case = $this->loadModel('testcase')->getById($caseID, $version); + $run = $this->testtask->getRunById($runID); } else { - $run = $this->testtask->getRunById($runID); + $run = new stdclass(); + $run->case = $this->loadModel('testcase')->getById($caseID, $version); } $caseID = $caseID ? $caseID : $run->case->id; @@ -737,10 +736,10 @@ class testtask extends control $this->view->run = $run; $this->view->preCase = $preCase; $this->view->nextCase = $nextCase; - $this->view->results = $this->testtask->getResults($runID, $caseID); $this->view->users = $this->loadModel('user')->getPairs('noclosed, noletter'); $this->view->caseID = $caseID; $this->view->version = $version; + $this->view->runID = $runID; die($this->display()); } @@ -806,12 +805,7 @@ class testtask extends control */ public function results($runID, $caseID = 0, $version = 0) { - if($caseID) - { - $case = $this->loadModel('testcase')->getByID($caseID, $version); - $results = $this->testtask->getResults(0, $caseID); - } - else + if($runID) { $case = $this->testtask->getRunById($runID)->case; $results = $this->testtask->getResults($runID); @@ -820,6 +814,11 @@ class testtask extends control $testtask = $this->dao->select('build, product')->from(TABLE_TESTTASK)->where('id')->eq($testtaskID)->fetch(); $this->view->build = isset($builds[$testtask->build]) ? $builds[$testtask->build] : ''; } + else + { + $case = $this->loadModel('testcase')->getByID($caseID, $version); + $results = $this->testtask->getResults(0, $caseID); + } $this->view->case = $case; $this->view->results = $results; diff --git a/module/testtask/model.php b/module/testtask/model.php index d6d952cd6e..86c3394787 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -285,7 +285,7 @@ class testtaskModel extends model ->beginIF($moduleID)->andWhere('t2.module')->in($moduleID)->fi() ->orderBy($orderBy) ->page($pager) - ->fetchAll(); + ->fetchAll('id'); } /** @@ -309,7 +309,7 @@ class testtaskModel extends model ->beginIF($modules)->andWhere('t2.module')->in($modules)->fi() ->orderBy($orderBy) ->page($pager) - ->fetchAll(); + ->fetchAll('id'); } /** @@ -374,7 +374,7 @@ class testtaskModel extends model ->beginIF($task->branch)->andWhere('t2.branch')->in("0,{$task->branch}")->fi() ->orderBy(strpos($sort, 'assignedTo') !== false ? ('t1.' . $sort) : ('t2.' . $sort)) ->page($pager) - ->fetchAll(); + ->fetchAll('id'); } return $runs; } @@ -573,13 +573,13 @@ class testtaskModel extends model */ public function getResults($runID, $caseID = 0) { - if($caseID > 0) - { - $results = $this->dao->select('*')->from(TABLE_TESTRESULT)->where('`case`')->eq($caseID)->orderBy('id desc')->fetchAll('id'); + if($runID > 0) + { + $results = $this->dao->select('*')->from(TABLE_TESTRESULT)->where('run')->eq($runID)->orderBy('id desc')->fetchAll('id'); } else { - $results = $this->dao->select('*')->from(TABLE_TESTRESULT)->where('run')->eq($runID)->orderBy('id desc')->fetchAll('id'); + $results = $this->dao->select('*')->from(TABLE_TESTRESULT)->where('`case`')->eq($caseID)->orderBy('id desc')->fetchAll('id'); } if(!$results) return array(); @@ -721,6 +721,12 @@ class testtaskModel extends model $assignedTo = zget($users, $run->assignedTo, $run->assignedTo); echo substr($assignedTo, strpos($assignedTo, ':') + 1); break; + case 'bugs': + echo $run->bugs; + break; + case 'results': + echo $run->results; + break; case 'actions': common::printIcon('testtask', 'runCase', "id=$run->id", '', 'list', '', '', 'runCase iframe'); common::printIcon('testtask', 'results', "id=$run->id", '', 'list', '', '', 'iframe'); diff --git a/module/testtask/view/cases.html.php b/module/testtask/view/cases.html.php index 057e0d64b9..a1b72ac325 100644 --- a/module/testtask/view/cases.html.php +++ b/module/testtask/view/cases.html.php @@ -47,7 +47,7 @@ var moduleID = ''; ?>
+
diff --git a/module/testtask/view/casesdata.html.php b/module/testtask/view/casesdata.html.php index 190686f5e6..67c3e3b289 100644 --- a/module/testtask/view/casesdata.html.php +++ b/module/testtask/view/casesdata.html.php @@ -10,19 +10,22 @@ * @link http://www.zentao.net */ ?> + id&browseType=$browseType¶m=$param&orderBy=%s&recToal={$pager->recTotal}&recPerPage={$pager->recPerPage}"; ?> - - - - - - - - - + + + + + + + + + + + @@ -52,6 +55,8 @@ + +
idAB);?> priAB);?> testcase->title);?> testcase->type);?> testtask->assignedTo);?> testtask->lastRunAccount);?> testtask->lastRunTime);?> testtask->lastRunResult);?> statusAB);?>idAB);?> priAB);?> testcase->title);?> testcase->type);?> testtask->assignedTo);?> testtask->lastRunAccount);?> testtask->lastRunTime);?> testtask->lastRunResult);?> statusAB);?> testcase->bugsAB;?> testcase->results?> actions;?>
lastRunDate)) echo date(DT_MONTHTIME1, strtotime($run->lastRunDate));?> lastRunResult) echo $lang->testcase->resultList[$run->lastRunResult];?> version < $run->caseVersion) ? "{$lang->testcase->changed}" : $lang->testtask->statusList[$run->status];?>bugs) ? html::a($this->createLink('testcase', 'bugs', "runID={$run->id}&caseID={$run->case}"), $run->bugs, '', "class='iframe'") : $run->bugs?>results) ? html::a($this->createLink('testtask', 'results', "runID={$run->id}&caseID={$run->case}"), $run->results, '', "class='iframe'") : $run->results?> id", '', 'list', '', '', 'runCase iframe'); diff --git a/module/testtask/view/runcase.html.php b/module/testtask/view/runcase.html.php index f3c85760b6..9203f0964d 100644 --- a/module/testtask/view/runcase.html.php +++ b/module/testtask/view/runcase.html.php @@ -129,7 +129,7 @@