From 32f805fee6cbe9845000981588bfb19aa9203580 Mon Sep 17 00:00:00 2001 From: sunguangming Date: Tue, 29 Jul 2025 02:55:55 +0000 Subject: [PATCH] * [bug#64376,done,0.5h] fix bug. --- module/testtask/model.php | 26 ++++++++++++++++++++----- module/testtask/test/model/linkcase.php | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/module/testtask/model.php b/module/testtask/model.php index 847932d668..9ca6686774 100755 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -824,10 +824,15 @@ class testtaskModel extends model $caseIdList = array_unique(array_filter(array_map(function($run){return $run->case;}, $runs))); if($type == 'bybuild' && $caseIdList) $users = $this->dao->select('`case`, assignedTo')->from(TABLE_TESTRUN)->where('`case`')->in($caseIdList)->fetchPairs(); - if($this->app->tab != 'qa') + if($this->app->tab == 'execution') { - $projectID = $this->app->tab == 'project' ? $this->session->project : $this->session->execution; - $lastOrder = $this->dao->select('MAX(`order`) AS `order`')->from(TABLE_PROJECTCASE)->where('project')->eq($projectID)->fetch('order'); + $execution = $this->loadModel('execution')->fetchByID((int)$this->session->execution); + $executionLastOrder = $this->dao->select('MAX(`order`) AS `order`')->from(TABLE_PROJECTCASE)->where('project')->eq((int)$execution->id)->fetch('order'); + $projectLastOrder = $this->dao->select('MAX(`order`) AS `order`')->from(TABLE_PROJECTCASE)->where('project')->eq((int)$execution->project)->fetch('order'); + } + elseif($this->app->tab == 'project') + { + $lastOrder = $this->dao->select('MAX(`order`) AS `order`')->from(TABLE_PROJECTCASE)->where('project')->eq((int)$this->session->project)->fetch('order'); } $case = new stdclass(); @@ -844,13 +849,24 @@ class testtaskModel extends model /* 在项目或执行下关联用例到测试单时把用例关联到项目或执行。*/ /* Associate the cases to the project or execution when associating the cases to the testtask under the project or execution. */ - if($this->app->tab != 'qa') + if($this->app->tab == 'project') { - $case->project = $projectID; + $case->project = (int)$this->session->project; $case->case = $run->case; $case->order = ++$lastOrder; $this->dao->replace(TABLE_PROJECTCASE)->data($case)->exec(); } + elseif($this->app->tab == 'execution') + { + $case->project = (int)$execution->id; + $case->case = $run->case; + $case->order = ++$executionLastOrder; + $this->dao->replace(TABLE_PROJECTCASE)->data($case)->exec(); + + $case->project = (int)$execution->project; + $case->order = ++$projectLastOrder; + $this->dao->replace(TABLE_PROJECTCASE)->data($case)->exec(); + } $this->action->create('case', $run->case, 'linked2testtask', '', $taskID); } diff --git a/module/testtask/test/model/linkcase.php b/module/testtask/test/model/linkcase.php index afd4ee4392..ee6bd8d42c 100755 --- a/module/testtask/test/model/linkcase.php +++ b/module/testtask/test/model/linkcase.php @@ -340,4 +340,4 @@ r($result['cases']) && p('1:project,product,case,version,order') && e('2,1,2,1,8 $result = $testtask->linkCaseTest(16, 'bybug', $cases1); r($result['cases']) && p('0:project,product,case,version,order') && e('2,1,1,1,9'); // 在执行 2 中按缺陷关联标签下关联用例 1,2 到测试单 16,查看关联后的执行 2 中的用例 1。 -r($result['cases']) && p('1:project,product,case,version,order') && e('2,1,2,1,10'); // 在执行 2 中按缺陷关联标签下关联用例 1,2 到测试单 16,查看关联后的执行 2 中的用例 2。 +r($result['cases']) && p('1:project,product,case,version,order') && e('2,1,2,1,10'); // 在执行 2 中按缺陷关联标签下关联用例 1,2 到测试单 16,查看关联后的执行 2 中的用例 2。 \ No newline at end of file