From 2996d56fa0e4c7e903c42e9391a40df4dc8a9420 Mon Sep 17 00:00:00 2001 From: liuhong Date: Tue, 3 Jan 2023 09:14:04 +0000 Subject: [PATCH] * Finish task #81778. --- module/testcase/config.php | 2 ++ module/testtask/control.php | 6 ++++++ module/testtask/lang/de.php | 1 + module/testtask/lang/en.php | 1 + module/testtask/lang/fr.php | 1 + module/testtask/lang/zh-cn.php | 1 + module/testtask/model.php | 26 +++++++++++++++----------- module/testtask/view/linkcase.html.php | 2 ++ 8 files changed, 29 insertions(+), 11 deletions(-) diff --git a/module/testcase/config.php b/module/testcase/config.php index 26acbca266..c5cadcf6f0 100644 --- a/module/testcase/config.php +++ b/module/testcase/config.php @@ -37,6 +37,7 @@ $config->testcase->excludeCheckFileds = ',pri,type,stage,needReview,story,branch global $lang; $config->testcase->search['module'] = 'testcase'; $config->testcase->search['fields']['title'] = $lang->testcase->title; +$config->testcase->search['fields']['storyTitle'] = $lang->testcase->linkStory; $config->testcase->search['fields']['id'] = $lang->testcase->id; $config->testcase->search['fields']['keywords'] = $lang->testcase->keywords; $config->testcase->search['fields']['lastEditedBy'] = $lang->testcase->lastEditedByAB; @@ -58,6 +59,7 @@ $config->testcase->search['fields']['openedDate'] = $lang->testcase->openedD $config->testcase->search['fields']['lastEditedDate'] = $lang->testcase->lastEditedDateAB; $config->testcase->search['params']['title'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->testcase->search['params']['storyTitle'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->testcase->search['params']['module'] = array('operator' => 'belong', 'control' => 'select', 'values' => 'modules'); $config->testcase->search['params']['keywords'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->testcase->search['params']['lastEditedBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); diff --git a/module/testtask/control.php b/module/testtask/control.php index d12e5cae63..8eb9073e49 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -1059,6 +1059,11 @@ class testtask extends control * Link cases to a test task. * * @param int $taskID + * @param string $type + * @param int $param + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * @access public * @return void */ @@ -1108,6 +1113,7 @@ class testtask extends control $this->config->testcase->search['style'] = 'simple'; if($product->shadow) unset($this->config->testcase->search['fields']['product']); + if($type != 'bystory') unset($this->config->testcase->search['fields']['storyTitle']); if($task->productType == 'normal') { unset($this->config->testcase->search['fields']['branch']); diff --git a/module/testtask/lang/de.php b/module/testtask/lang/de.php index 481fabdaa5..fa6ab7c3ad 100644 --- a/module/testtask/lang/de.php +++ b/module/testtask/lang/de.php @@ -131,6 +131,7 @@ $lang->testtask->priList[2] = '2'; $lang->testtask->priList[3] = '3'; $lang->testtask->priList[4] = '4'; +$lang->testcase->linkStory = 'linkStory'; $lang->testtask->unlinkedCases = 'Unverknüpfte Fälle'; $lang->testtask->linkByBuild = 'Mit Build verknüpfen'; $lang->testtask->linkByStory = 'Mit Story verknüpfen'; diff --git a/module/testtask/lang/en.php b/module/testtask/lang/en.php index 28a1f09374..08f54f1403 100644 --- a/module/testtask/lang/en.php +++ b/module/testtask/lang/en.php @@ -131,6 +131,7 @@ $lang->testtask->priList[2] = '2'; $lang->testtask->priList[3] = '3'; $lang->testtask->priList[4] = '4'; +$lang->testcase->linkStory = 'linkStory'; $lang->testtask->unlinkedCases = 'Unlinked Case'; $lang->testtask->linkByBuild = 'Copy from build'; $lang->testtask->linkByStory = 'Link by Story'; diff --git a/module/testtask/lang/fr.php b/module/testtask/lang/fr.php index 40eaf40f0f..36b9f0f3f5 100644 --- a/module/testtask/lang/fr.php +++ b/module/testtask/lang/fr.php @@ -131,6 +131,7 @@ $lang->testtask->priList[2] = '2'; $lang->testtask->priList[3] = '3'; $lang->testtask->priList[4] = '4'; +$lang->testcase->linkStory = 'linkStory'; $lang->testtask->unlinkedCases = 'CasTests Non rattachés'; $lang->testtask->linkByBuild = 'Copier depuis build'; $lang->testtask->linkByStory = 'Lier par Story'; diff --git a/module/testtask/lang/zh-cn.php b/module/testtask/lang/zh-cn.php index 74c93f4342..33759d1927 100644 --- a/module/testtask/lang/zh-cn.php +++ b/module/testtask/lang/zh-cn.php @@ -131,6 +131,7 @@ $lang->testtask->priList[2] = '2'; $lang->testtask->priList[3] = '3'; $lang->testtask->priList[4] = '4'; +$lang->testcase->linkStory = '关联需求'; $lang->testtask->unlinkedCases = '未关联'; $lang->testtask->linkByBuild = '复制测试单'; $lang->testtask->linkByStory = "按{$lang->SRCommon}关联"; diff --git a/module/testtask/model.php b/module/testtask/model.php index 11c07e5f8e..ab98d62ac7 100755 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -346,6 +346,7 @@ class testtaskModel extends model { if($this->session->testcaseQuery == false) $this->session->set('testcaseQuery', ' 1 = 1'); $query = $this->session->testcaseQuery; + if(strpos($query, 'storyTitle') !== false and $type != 'bystory') $query = '1 = 1'; $allProduct = "`product` = 'all'"; if(strpos($query, '`product` =') === false && $type != 'bysuite') $query .= " AND `product` = $productID"; if(strpos($query, $allProduct) !== false) $query = str_replace($allProduct, '1', $query); @@ -399,18 +400,21 @@ class testtaskModel extends model { $stories = $this->dao->select('stories')->from(TABLE_BUILD)->where('id')->eq($task->build)->fetch('stories'); $cases = array(); + $query = preg_replace('/`(\w+)`/', 't1.`$1`', $query); + if(strpos($query, '`storyTitle`') !== false) $query = str_replace('t1.`storyTitle`', 't2.`title`', $query); if($stories) { - $cases = $this->dao->select('*')->from(TABLE_CASE) + $cases = $this->dao->select('t1.*,t2.title as storyTitle')->from(TABLE_CASE)->alias('t1') + ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') ->where($query) ->beginIF($this->lang->navGroup->testtask != 'qa')->andWhere('project')->eq($this->session->project)->fi() - ->andWhere('product')->eq($productID) - ->andWhere('status')->ne('wait') - ->beginIF($linkedCases)->andWhere('id')->notIN($linkedCases)->fi() - ->beginIF($task->branch !== '')->andWhere('branch')->in("0,$task->branch")->fi() - ->andWhere('story')->in(trim($stories, ',')) - ->andWhere('deleted')->eq(0) - ->orderBy('id desc') + ->andWhere('t1.product')->eq($productID) + ->andWhere('t1.status')->ne('wait') + ->beginIF($linkedCases)->andWhere('t1.id')->notIN($linkedCases)->fi() + ->beginIF($task->branch !== '')->andWhere('t1.branch')->in("0,$task->branch")->fi() + ->andWhere('t1.story')->in(trim($stories, ',')) + ->andWhere('t1.deleted')->eq(0) + ->orderBy('t1.id desc') ->page($pager) ->fetchAll(); } @@ -1500,7 +1504,7 @@ class testtaskModel extends model $failHtml = ': ' . $this->lang->testtask->fail . ''; $passHtml = ': ' . $this->lang->testtask->pass . ''; - + $log = preg_replace(array("/:\x20失败/", "/:\x20fail/", "/:\x20成功/", "/:\x20pass/"), array($failHtml, $failHtml, $passHtml, $passHtml), $log); $logHtml .= "
  • " . $log . "
  • "; @@ -1524,11 +1528,11 @@ class testtaskModel extends model } $caseResult = $passCount ? 'pass':'fail'; - $logHtml .= "
  • " + $logHtml .= "
  • " . sprintf($this->lang->testtask->stepSummary, $total, $passCount, $failCount) . "
  • "; } - + return $logHtml; } diff --git a/module/testtask/view/linkcase.html.php b/module/testtask/view/linkcase.html.php index e052cb5e1b..c79a193708 100644 --- a/module/testtask/view/linkcase.html.php +++ b/module/testtask/view/linkcase.html.php @@ -86,6 +86,7 @@ testtask->linkVersion;?> priAB;?> testcase->title;?> + testcase->linkStory;?> testcase->type;?> openedByAB;?> testtask->lastRunAccount;?> @@ -112,6 +113,7 @@ echo ')'; ?> + story and $case->storyTitle) echo html::a(helper ::createLink('story', 'view', "storyID=$case->story"), $case->storyTitle);?> testcase->typeList[$case->type];?> openedBy);?> lastRunner);?>