diff --git a/module/testcase/config.php b/module/testcase/config.php index 6987f5c481..a3441ad07e 100644 --- a/module/testcase/config.php +++ b/module/testcase/config.php @@ -26,5 +26,7 @@ $config->testcase->search['params']['pri'] = array('operator' => '=', $config->testcase->search['params']['type'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->testcase->typeList); $config->testcase->search['params']['stage'] = array('operator' => 'include', 'control' => 'select', 'values' => $lang->testcase->stageList); +$config->testcase->defaultSteps = 3; + $config->testcase->create->requiredFields = 'title,type'; $config->testcase->edit->requiredFields = 'title,type'; diff --git a/module/testcase/control.php b/module/testcase/control.php index 281328ddcc..7e5d47b078 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -145,7 +145,7 @@ class testcase extends control * @access public * @return void */ - public function create($productID, $moduleID = 0) + public function create($productID, $moduleID = 0, $testcaseID = 0) { $this->loadModel('story'); if(!empty($_POST)) @@ -165,6 +165,37 @@ class testcase extends control /* Set menu. */ $this->testcase->setMenu($this->products, $productID); + /* Init vars. */ + $pri = 0; + $storyID = 0; + $type = ''; + $stage = ''; + $title = ''; + $keywords = ''; + $steps = array(); + + if($testcaseID > 0) + { + $testcase = $this->testcase->getById($testcaseID); + $productID = $testcase->product; + $type = $testcase->type ? $testcase->type : 'feature'; + $stage = $testcase->stage; + $pri = $testcase->pri; + $storyID = $testcase->story; + $title = $testcase->title; + $keywords = $testcase->keywords; + $steps = $testcase->steps; + } + + /* Padding the steps to the default steps count. */ + if(count($steps) < $this->config->testcase->defaultSteps) + { + $paddingCount = $this->config->testcase->defaultSteps - count($steps); + $step->desc = ''; + $step->expect = ''; + for($i = 1; $i <= $paddingCount; $i ++) $steps[] = $step; + } + $header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->create; $position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]); $position[] = $this->lang->testcase->create; @@ -178,6 +209,13 @@ class testcase extends control $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0); $this->view->currentModuleID = $currentModuleID; $this->view->stories = $this->story->getProductStoryPairs($productID); + $this->view->type = $type; + $this->view->stage = $stage; + $this->view->pri = $pri; + $this->view->storyID = $storyID; + $this->view->title = $title; + $this->view->keywords = $keywords; + $this->view->steps = $steps; $this->display(); } diff --git a/module/testcase/view/create.html.php b/module/testcase/view/create.html.php index ca17a4d443..d447f6d42e 100644 --- a/module/testcase/view/create.html.php +++ b/module/testcase/view/create.html.php @@ -23,23 +23,23 @@ testcase->type;?> - testcase->typeList, 'feature', 'class=select-3');?> + testcase->typeList, $type, 'class=select-3');?> testcase->stage;?> - testcase->stageList, '', "class='select-3' multiple='multiple'");?> + testcase->stageList, $stage, "class='select-3' multiple='multiple'");?> testcase->pri;?> - testcase->priList, '', 'class=select-3');?> + testcase->priList, $pri, 'class=select-3');?> testcase->lblStory;?> - + testcase->title;?> - + testcase->steps;?> @@ -52,16 +52,17 @@ actions;?> $step) { - echo ""; - echo "$i"; - echo '' . html::textarea('steps[]', '', "rows='3' class='w-p100'") . ''; - echo '' . html::textarea('expects[]', '', "rows='3' class='w-p100'") . ''; + $stepID += 1; + echo ""; + echo "$stepID"; + echo '' . html::textarea('steps[]', $step->desc, "rows='3' class='w-p100'") . ''; + echo '' . html::textarea('expects[]', $step->expect, "rows='3' class='w-p100'") . ''; echo ""; - echo "
"; - echo "
"; - echo "
"; + echo "
"; + echo "
"; + echo "
"; echo "
"; echo ''; } @@ -71,7 +72,7 @@ testcase->keywords;?> - + testcase->files;?>