diff --git a/db/zentao.sql b/db/zentao.sql
index e829c1d528..1a9cb41e34 100644
--- a/db/zentao.sql
+++ b/db/zentao.sql
@@ -166,6 +166,7 @@ CREATE TABLE IF NOT EXISTS `zt_case` (
`linkCase` varchar(255) NOT NULL,
`fromBug` mediumint(8) unsigned NOT NULL,
`fromCaseID` mediumint(8) unsigned NOT NULL,
+ `fromCaseVersion` mediumint(8) unsigned NOT NULL,
`deleted` enum('0','1') NOT NULL default '0',
`lastRunner` varchar(30) NOT NULL,
`lastRunDate` datetime NOT NULL,
diff --git a/module/testcase/control.php b/module/testcase/control.php
index fe3b6e63fd..8dae13af0e 100644
--- a/module/testcase/control.php
+++ b/module/testcase/control.php
@@ -988,9 +988,10 @@ class testcase extends control
* @access public
* @return void
*/
- public function confirmLibcaseChange($caseID, $libcaseID, $version)
+ public function confirmLibcaseChange($caseID, $libcaseID)
{
- $case = $this->testcase->getById($caseID);
+ $case = $this->testcase->getById($caseID);
+ $version = $case->fromCaseVersion;
$this->dao->update(TABLE_CASE)->set('version')->eq($version)->where('id')->eq($caseID)->exec();
$steps = $this->dao->select('*')->from(TABLE_CASESTEP)->where('`case`')->eq($libcaseID)->andWhere('version')->eq($version)->fetchAll();
foreach($steps as $step)
@@ -1002,6 +1003,20 @@ class testcase extends control
die(js::reload('parent'));
}
+ /**
+ * Ignore libcase changed.
+ *
+ * @param int $caseID
+ * @access public
+ * @return void
+ */
+ public function ignoreLibcaseChange($caseID)
+ {
+ $case = $this->testcase->getById($caseID);
+ $this->dao->update(TABLE_CASE)->set('fromCaseVersion')->eq($case->version)->where('id')->eq($caseID)->exec();
+ die(js::reload('parent'));
+ }
+
/**
* Confirm story changes.
*
diff --git a/module/testcase/lang/en.php b/module/testcase/lang/en.php
index 6eec3173f3..9a59fbf960 100644
--- a/module/testcase/lang/en.php
+++ b/module/testcase/lang/en.php
@@ -65,6 +65,7 @@ $lang->testcase->createBug = 'Convert to Bug';
$lang->testcase->fromModule = 'Source Module';
$lang->testcase->fromCase = 'Source Case';
$lang->testcase->sync = 'Sync Case';
+$lang->testcase->ignore = 'Ignore';
$lang->testcase->fromTesttask = 'From Testtask';
$lang->testcase->fromCaselib = 'From Caselib';
$lang->case = $lang->testcase; // For dao checking using. Because 'case' is a php keywords, so the module name is testcase, table name is still case.
diff --git a/module/testcase/lang/zh-cn.php b/module/testcase/lang/zh-cn.php
index d9c8f59d4b..5f78be7927 100644
--- a/module/testcase/lang/zh-cn.php
+++ b/module/testcase/lang/zh-cn.php
@@ -65,6 +65,7 @@ $lang->testcase->createBug = '转Bug';
$lang->testcase->fromModule = '来源模块';
$lang->testcase->fromCase = '来源用例';
$lang->testcase->sync = '同步';
+$lang->testcase->ignore = '忽略';
$lang->testcase->fromTesttask = '测试单用例';
$lang->testcase->fromCaselib = '用例库用例';
$lang->case = $lang->testcase; // 用于DAO检查时使用。因为case是系统关键字,所以无法定义该模块为case,只能使用testcase,但表还是使用的case。
diff --git a/module/testcase/model.php b/module/testcase/model.php
index 1e7f8a6f99..13006067a3 100644
--- a/module/testcase/model.php
+++ b/module/testcase/model.php
@@ -396,7 +396,6 @@ class testcaseModel extends model
$case->latestStoryVersion = $story->version;
}
if($case->fromBug) $case->fromBugTitle = $this->dao->findById($case->fromBug)->from(TABLE_BUG)->fields('title')->fetch('title');
- if($case->fromCaseID) $case->libCaseVersion = $this->dao->findById($case->fromCaseID)->from(TABLE_CASE)->fetch('version');
$case->toBugs = array();
$toBugs = $this->dao->select('id, title')->from(TABLE_BUG)->where('`case`')->eq($caseID)->fetchAll();
@@ -672,6 +671,8 @@ class testcaseModel extends model
if($stepChanged)
{
$parentStepID = 0;
+ $isLibCase = ($oldCase->lib and empty($oldCase->product));
+ if($isLibCase) $this->dao->update(TABLE_CASE)->set('`fromCaseVersion`')->eq($version)->where('`fromCaseID`')->eq($caseID)->exec();
foreach($this->post->steps as $stepID => $stepDesc)
{
if(empty($stepDesc)) continue;
@@ -1253,7 +1254,8 @@ class testcaseModel extends model
$libSteps = $this->dao->select('*')->from(TABLE_CASESTEP)->where('`case`')->in($data->caseIdList)->orderBy('id')->fetchGroup('case');
foreach($libCases as $libCaseID => $case)
{
- $case->fromCaseID = $case->id;
+ $case->fromCaseID = $case->id;
+ $case->fromCaseVersion = $case->version;
$case->product = $productID;
if(isset($data->module[$case->id])) $case->module = $data->module[$case->id];
if(isset($data->branch[$case->id])) $case->branch = $data->branch[$case->id];
@@ -1339,7 +1341,6 @@ class testcaseModel extends model
$caseLink = helper::createLink('testcase', 'view', "caseID=$case->id&version=$case->version");
$account = $this->app->user->account;
$fromCaseID = $case->fromCaseID;
- if($fromCaseID) $libCaseVersion = $this->dao->findById($fromCaseID)->from(TABLE_CASE)->fetch('version');
$id = $col->id;
if($col->show)
{
@@ -1392,7 +1393,7 @@ class testcaseModel extends model
{
print("lang->testcase->fromTesttask}>{$this->lang->story->changed}");
}
- elseif(isset($libCaseVersion) and $libCaseVersion > $case->version and !$case->needconfirm)
+ elseif(isset($case->fromCaseVersion) and $case->fromCaseVersion > $case->version and !$case->needconfirm)
{
print("lang->testcase->fromCaselib}>{$this->lang->testcase->changed}");
}
diff --git a/module/testcase/view/view.html.php b/module/testcase/view/view.html.php
index 539ac2d16e..9067b0ff5c 100644
--- a/module/testcase/view/view.html.php
+++ b/module/testcase/view/view.html.php
@@ -223,10 +223,11 @@
echo html::a($this->createLink('testcase', 'confirmchange', "caseID=$case->id"), $lang->testcase->sync, 'hiddenwin', "class='btn btn-mini btn-info'");
echo ")";
}
- if(isset($case->libCaseVersion) and $case->libCaseVersion > $case->version and $from != 'testtask')
+ if(isset($case->fromCaseVersion) and $case->fromCaseVersion > $case->version and $from != 'testtask')
{
echo "(testcase->fromCaselib}>{$lang->testcase->changed} ";
- echo html::a($this->createLink('testcase', 'confirmLibcaseChange', "caseID=$case->id&libcaseID=$case->fromCaseID&version=$case->libCaseVersion"), $lang->testcase->sync, 'hiddenwin', "class='btn btn-mini btn-info'");
+ echo html::a($this->createLink('testcase', 'confirmLibcaseChange', "caseID=$case->id&libcaseID=$case->fromCaseID"), $lang->testcase->sync, 'hiddenwin', "class='btn btn-mini btn-info'");
+ echo html::a($this->createLink('testcase', 'ignoreLibcaseChange', "caseID=$case->id"), $lang->testcase->ignore, 'hiddenwin', "class='btn btn-mini btn-info'");
echo ")";
}
?>