* Refactor the getStatus function.
This commit is contained in:
@@ -2316,89 +2316,6 @@ class testcaseModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get status for different method.
|
||||
*
|
||||
* @param string $methodName
|
||||
* @param object $case
|
||||
* @access public
|
||||
* @return mixed string | bool | array
|
||||
*/
|
||||
public function getStatus($methodName, $case = null)
|
||||
{
|
||||
if($methodName == 'create')
|
||||
{
|
||||
if($this->forceNotReview() || !$this->post->needReview) return 'normal';
|
||||
return 'wait';
|
||||
}
|
||||
|
||||
if($methodName == 'review')
|
||||
{
|
||||
$status = zget($case, 'status', '');
|
||||
|
||||
if($this->post->result == 'pass') return 'normal';
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
if($methodName == 'update')
|
||||
{
|
||||
if(!empty($_POST['lastEditedDate']) and $case->lastEditedDate != $this->post->lastEditedDate)
|
||||
{
|
||||
dao::$errors[] = $this->lang->error->editedByOther;
|
||||
return false;
|
||||
}
|
||||
|
||||
$status = $this->post->status ? $this->post->status : $case->status;
|
||||
$stepChanged = false;
|
||||
$steps = array();
|
||||
|
||||
/* ---------------- Judge steps changed or not.-------------------- */
|
||||
|
||||
/* Remove the empty setps in post. */
|
||||
if($this->post->steps)
|
||||
{
|
||||
$data = fixer::input('post')->get();
|
||||
foreach($data->steps as $key => $desc)
|
||||
{
|
||||
$desc = trim($desc);
|
||||
$stepType = isset($data->stepType[$key]) ? $data->stepType[$key] : 'step';
|
||||
if(!empty($desc)) $steps[] = array('desc' => $desc, 'type' => $stepType, 'expect' => trim(zget($data->expects, $key, '')));
|
||||
}
|
||||
|
||||
/* If step count changed, case changed. */
|
||||
if(count($case->steps) != count($steps))
|
||||
{
|
||||
$stepChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Compare every step. */
|
||||
$i = 0;
|
||||
foreach($case->steps as $key => $oldStep)
|
||||
{
|
||||
if(trim($oldStep->desc) != trim($steps[$i]['desc']) or trim($oldStep->expect) != $steps[$i]['expect'] or trim($oldStep->type) != $steps[$i]['type'])
|
||||
{
|
||||
$stepChanged = true;
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$this->forceNotReview() and $stepChanged) $status = 'wait';
|
||||
|
||||
if(!empty($_POST['title']) and $case->title != $this->post->title) $stepChanged = true;
|
||||
if(!empty($_POST['precondition']) and $case->precondition != $this->post->precondition) $stepChanged = true;
|
||||
|
||||
return array($stepChanged, $status);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* processDatas
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user