diff --git a/module/testcase/model.php b/module/testcase/model.php index 360cdf8777..6f4df04158 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -71,16 +71,17 @@ class testcaseModel extends model foreach($this->post->steps as $stepID => $stepDesc) { if(empty($stepDesc)) continue; - $isGroup = isset($_POST['stepType'][$stepID]); + $stepType = $this->post->stepType; $step = new stdClass(); - $step->parent = $isGroup ? 0 : $parentStepID; + $step->type = ($stepType[$stepID] == 'item' and $parentStepID == 0) ? 'step' : $stepType[$stepID]; + $step->parent = ($step->type == 'item') ? $parentStepID : 0; $step->case = $caseID; $step->version = 1; - $step->type = $isGroup ? 'group' : 'item'; $step->desc = htmlspecialchars($stepDesc); $step->expect = htmlspecialchars($this->post->expects[$stepID]); $this->dao->insert(TABLE_CASESTEP)->data($step)->autoCheck()->exec(); - if($isGroup) $parentStepID = $this->dao->lastInsertID(); + if($step->type == 'group') $parentStepID = $this->dao->lastInsertID(); + if($step->type == 'step') $parentStepID = 0; } return array('status' => 'created', 'id' => $caseID); } @@ -528,16 +529,17 @@ class testcaseModel extends model foreach($this->post->steps as $stepID => $stepDesc) { if(empty($stepDesc)) continue; - $isGroup = isset($_POST['stepType'][$stepID]); + $stepType = $this->post->stepType; $step = new stdclass(); - $step->parent = $isGroup ? 0 : $parentStepID; + $step->type = ($stepType[$stepID] == 'item' and $parentStepID == 0) ? 'step' : $stepType[$stepID]; + $step->parent = ($step->type == 'item') ? $parentStepID : 0; $step->case = $caseID; $step->version = $version; - $step->type = $isGroup ? 'group' : 'item'; $step->desc = htmlspecialchars($stepDesc); $step->expect = htmlspecialchars($this->post->expects[$stepID]); $this->dao->insert(TABLE_CASESTEP)->data($step)->autoCheck()->exec(); - if($isGroup) $parentStepID = $this->dao->lastInsertID(); + if($step->type == 'group') $parentStepID = $this->dao->lastInsertID(); + if($step->type == 'step') $parentStepID = 0; } } diff --git a/module/testcase/view/view.html.php b/module/testcase/view/view.html.php index a554d9365d..dc61ad7a24 100644 --- a/module/testcase/view/view.html.php +++ b/module/testcase/view/view.html.php @@ -97,16 +97,16 @@ foreach($case->steps as $stepID => $step) { $stepClass = "step-{$step->type}"; - if($step->type == 'group' or ($step->type == 'item' and $step->parent == 0)) + if($step->type == 'group' or $step->type == 'step') { $stepId++; $childId = 0; } - if($step->type == 'item' and $step->parent == 0) $stepClass = 'step-group'; + if($step->type == 'step') $stepClass = 'step-group'; echo "