* testcase: refactor the createScene method.

This commit is contained in:
liugang
2023-08-28 15:30:26 +08:00
parent 8e3bcdb370
commit 2ddcad386d
2 changed files with 20 additions and 19 deletions
+13 -18
View File
@@ -2723,14 +2723,8 @@ class testcaseModel extends model
* @access public
* @return bool
*/
public function createScene(): bool
public function createScene(object $scene): bool
{
$scene = fixer::input('post')
->add('openedBy', $this->app->user->account)
->add('openedDate', helper::now())
->cleanInt('product,module,branch,parent')
->get();
$this->dao->insert(TABLE_SCENE)->data($scene)
->autoCheck()
->batchCheck($this->config->testcase->createscene->requiredFields, 'notempty')
@@ -2740,20 +2734,21 @@ class testcaseModel extends model
if(dao::isError()) return false;
$sceneID = $this->dao->lastInsertID();
$scene->path = ',' . $sceneID . ',';
$scene->grade = 1;
if($scene->parent)
{
$parent = $this->getSceneByID($scene->parent);
$scene->path = $parent->path . $sceneID . ',';
$scene->grade = ++$parent->grade;
$scene->product = $parent->product;
$scene->branch = $parent->branch;
$scene->module = $parent->module;
}
else
{
$scene->path = ',' . $sceneID . ',';
$scene->grade = 1;
if($parent)
{
$scene->path = $parent->path . $sceneID . ',';
$scene->grade = ++$parent->grade;
$scene->product = $parent->product;
$scene->branch = $parent->branch;
$scene->module = $parent->module;
}
}
$this->dao->update(TABLE_SCENE)->data($scene)->where('id')->eq($sceneID)->exec();