From 39ea974c857270acd321aed5bb3c83d6bf757b35 Mon Sep 17 00:00:00 2001 From: "chencongzhi520@gmail.com" Date: Sat, 29 Oct 2011 12:24:40 +0000 Subject: [PATCH] * code for task#571 --- module/testcase/control.php | 10 ++++------ module/testcase/model.php | 4 +++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/module/testcase/control.php b/module/testcase/control.php index 5dbed9388f..b676c6b7da 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -162,10 +162,13 @@ class testcase extends control */ public function create($productID, $moduleID = 0, $from = '', $param = 0) { + $testcaseID = $from == 'testcase' ? $param : 0; + $bugID = $from == 'bug' ? $param : 0; + $this->loadModel('story'); if(!empty($_POST)) { - $this->testcase->create(); + $this->testcase->create($bugID); if(dao::isError()) die(js::error(dao::getError())); $this->loadModel('action'); $this->action->create('case', $caseID, 'Opened'); @@ -185,16 +188,11 @@ class testcase extends control $stage = ''; $pri = 0; $storyID = 0; - $testcaseID = 0; - $bugID = 0; $title = ''; $precondition = ''; $keywords = ''; $steps = array(); - if($from == 'testcase') $testcaseID = $param; - if($from == 'bug') $bugID = $param; - /* If testcaseID large than 0, use this testcase as template. */ if($testcaseID > 0) { diff --git a/module/testcase/model.php b/module/testcase/model.php index 725df6df9d..da7c13998e 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -35,10 +35,11 @@ class testcaseModel extends model /** * Create a case. * + * @param int $bugID * @access public * @return void */ - function create() + function create($bugID) { $now = helper::now(); $case = fixer::input('post') @@ -46,6 +47,7 @@ class testcaseModel extends model ->add('openedDate', $now) ->add('status', 'normal') ->add('version', 1) + ->add('fromBug', $bugID) ->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story)) ->remove('steps,expects,files,labels') ->setDefault('story', 0)