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 @@
| testcase->id?> | +testcase->id?> | testcase->title?> | -testcase->module?> | -testcase->story?> | + +testcase->branch?> | + +testcase->module?> | +testcase->story?> | testcase->pri?> | testcase->type?> | testcase->status?> | @@ -46,11 +49,14 @@ ?>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'")?> |
|---|