From c2121de201788d7b24e459cb791fd6bea07d0ddc Mon Sep 17 00:00:00 2001 From: Yagami Date: Wed, 20 Feb 2019 10:47:06 +0800 Subject: [PATCH] * Finish task #5267. --- module/testcase/control.php | 7 +++--- module/testcase/lang/en.php | 1 + module/testcase/lang/zh-cn.php | 1 + module/testcase/model.php | 36 +++++++++++++++++++++++++++++- module/testcase/view/edit.html.php | 1 + 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/module/testcase/control.php b/module/testcase/control.php index ec65893fe0..b1017e7134 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -593,9 +593,10 @@ class testcase extends control $title = "CASE #$case->id $case->title - " . $libraries[$case->lib]; $position[] = html::a($this->createLink('testsuite', 'library', "libID=$case->lib"), $libraries[$case->lib]); - $this->view->libID = $case->lib; - $this->view->libName = $libraries[$case->lib]; - $this->view->libraries = $libraries; + $this->view->libID = $case->lib; + $this->view->libName = $libraries[$case->lib]; + $this->view->libraries = $libraries; + $this->view->linkedCaseID = $this->testcase->getLinkedCaseID($case->lib, $caseID); $this->view->moduleOptionMenu = $this->tree->getOptionMenu($case->lib, $viewType = 'caselib', $startModuleID = 0); } else diff --git a/module/testcase/lang/en.php b/module/testcase/lang/en.php index a89a21d2e9..d3d069d399 100644 --- a/module/testcase/lang/en.php +++ b/module/testcase/lang/en.php @@ -139,6 +139,7 @@ $lang->testcase->confirmDelete = 'Do you want to delete this Test Case?'; $lang->testcase->confirmBatchDelete = 'Do you want to batch delete these Test Cases?'; $lang->testcase->ditto = 'Ditto'; $lang->testcase->dittoNotice = 'This Case does not belong to the Product as the previous one!'; +$lang->testcase->haveLinkCase = 'It has linked case, update this one, the linked case will change.'; $lang->testcase->reviewList[0] = 'NO'; $lang->testcase->reviewList[1] = 'YES'; diff --git a/module/testcase/lang/zh-cn.php b/module/testcase/lang/zh-cn.php index 8983c59994..faef133b49 100644 --- a/module/testcase/lang/zh-cn.php +++ b/module/testcase/lang/zh-cn.php @@ -139,6 +139,7 @@ $lang->testcase->confirmDelete = '您确认要删除该测试用例吗?'; $lang->testcase->confirmBatchDelete = '您确认要批量删除这些测试用例吗?'; $lang->testcase->ditto = '同上'; $lang->testcase->dittoNotice = '该用例与上一用例不属于同一产品!'; +$lang->testcase->haveLinkCase = '此用例存在相关用例,更新后,其相关用例会一并更新。'; $lang->testcase->reviewList[0] = '否'; $lang->testcase->reviewList[1] = '是'; diff --git a/module/testcase/model.php b/module/testcase/model.php index 382b597292..1a94ceb3a9 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -604,6 +604,24 @@ class testcaseModel extends model return $caseCounts; } + /** + * Check have imported cases or not. + * + * @param int $libID + * @param int $caseID$ + * @access public + * @return int + */ + public function getLinkedCaseID($libID, $caseID) + { + $linkedCaseID = $this->dao->select('id')->from(TABLE_CASE) + ->where('lib')->eq($libID) + ->andWhere('fromCaseID')->eq($caseID) + ->andWhere('deleted')->eq(0) + ->fetch('id'); + return $linkedCaseID; + } + /** * Update a case. * @@ -613,7 +631,10 @@ class testcaseModel extends model */ public function update($caseID) { - $oldCase = $this->getById($caseID); + $oldCase = $this->getById($caseID); + $isLibCase = ($oldCase->lib and empty($oldCase->product)); + $linkedCases = ''; + if($isLibCase) $linkedCases = $this->dao->select('id')->from(TABLE_CASE)->where('fromCaseID')->eq($caseID)->fetchPairs(); if(!empty($_POST['lastEditedDate']) and $oldCase->lastEditedDate != $this->post->lastEditedDate) { dao::$errors[] = $this->lang->error->editedByOther; @@ -666,6 +687,10 @@ class testcaseModel extends model ->get(); if(!$this->forceNotReview() and $stepChanged) $case->status = 'wait'; $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->batchCheck($this->config->testcase->edit->requiredFields, 'notempty')->where('id')->eq((int)$caseID)->exec(); + if($isLibCase and $linkedCases) + { + foreach($linkedCases as $linkedCaseID) $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->batchCheck($this->config->testcase->edit->requiredFields, 'notempty')->where('id')->eq((int)$linkedCaseID)->exec(); + } if(!$this->dao->isError()) { if($stepChanged) @@ -685,6 +710,15 @@ class testcaseModel extends model $this->dao->insert(TABLE_CASESTEP)->data($step)->autoCheck()->exec(); if($step->type == 'group') $parentStepID = $this->dao->lastInsertID(); if($step->type == 'step') $parentStepID = 0; + + if($isLibCase and $linkedCases) + { + foreach($linkedCases as $linkedCaseID) + { + $step->case = $linkedCaseID; + $this->dao->insert(TABLE_CASESTEP)->data($step)->autoCheck()->exec(); + } + } } } diff --git a/module/testcase/view/edit.html.php b/module/testcase/view/edit.html.php index 16478f6e1e..5a561e7418 100644 --- a/module/testcase/view/edit.html.php +++ b/module/testcase/view/edit.html.php @@ -125,6 +125,7 @@ lastEditedDate);?> createLink('testcase', 'browse', "productID=$productID");?>"' /> + ' . $lang->testcase->haveLinkCase . ''; ?>