* [task#149142,done,3h,0h] Upgrade testcase stagelist to deliverable.

This commit is contained in:
wangyuting
2025-09-11 11:15:26 +08:00
parent 0011dd7fd9
commit bcae791f34
3 changed files with 121 additions and 10 deletions
+27 -4
View File
@@ -216,7 +216,7 @@ class customZen extends custom
$this->checkDuplicateKeys($module, $field);
if(dao::$errors) return false;
$this->checkInvalidKeys($module, $field);
$oldCustoms = $this->checkInvalidKeys($module, $field);
if(dao::$errors) return false;
$lang = $_POST['lang'];
@@ -225,6 +225,29 @@ class customZen extends custom
if($lang == 'all') $this->custom->deleteItems("lang={$currentLang}&module={$module}&section={$field}&vision={$this->config->vision}");
$this->checkEmptyKeys($module, $field);
if($module == 'testcase' && $field == 'stageList')
{
$oldItems = array();
foreach($oldCustoms as $key => $item) $oldItems[$key] = $item->value;
$oldItems = arrayUnion($oldItems, zget($this->lang->$module, $field, array()));
$newItems = array();
$newCustoms = $this->custom->getItems("lang={$lang}&module={$module}&section={$field}");
foreach($newCustoms as $key => $item) $newItems[$key] = $item->value;
$addItems = array_diff_key($newItems, $oldItems);
$delItems = array_diff_key($oldItems, $newItems);
$changeItems = array();
foreach($oldItems as $key => $item)
{
if(!empty($newItems[$key]) && $newItems[$key] != $item) $changeItems[$key] = $newItems[$key];
}
$this->loadModel('upgrade');
if($addItems) $this->upgrade->createTestcaseDeliverable($addItems);
if($delItems) $this->upgrade->deleteTestcaseDeliverable($delItems);
if($changeItems) $this->upgrade->changeTestcaseDeliverable($changeItems);
}
return !dao::isError();
}
@@ -259,9 +282,9 @@ class customZen extends custom
* @param string $module todo|story|task|bug|testcase|testtask|user|project
* @param string $field priList|typeList|statusList|sourceList|reasonList|stageList|reviewRules|reviewResultList|review|severityList|osList|browserList|resolutionList|longlife|resultList|roleList|contactField|deleted|unitList
* @access protected
* @return bool|string
* @return array|string
*/
protected function checkInvalidKeys(string $module = 'story', string $field = 'priList'): bool|string
protected function checkInvalidKeys(string $module = 'story', string $field = 'priList'): array|string
{
$lang = $_POST['lang'];
$oldCustoms = $this->custom->getItems("lang={$lang}&module={$module}&section={$field}");
@@ -287,7 +310,7 @@ class customZen extends custom
if((in_array($module, array('bug', 'testcase')) || (in_array($module, array('story', 'task')) && $field == 'reasonList')) && strlen($key) > 30) return dao::$errors['message'] = $this->lang->custom->notice->invalidStrlen['thirty'];
}
return true;
return $oldCustoms;
}
/**
+1 -1
View File
@@ -104,7 +104,7 @@ $lang->upgrade->projectName = '项目名称';
$lang->upgrade->projectManage = '项目管理';
$lang->upgrade->compatibleEXT = '扩展机制兼容';
$lang->upgrade->fileName = '文件名称';
$lang->upgrade->list = '列表';
$lang->upgrade->list = '的列表';
$lang->upgrade->next = '下一步';
$lang->upgrade->back = '上一步';
+93 -5
View File
@@ -11547,9 +11547,9 @@ class upgradeModel extends model
* Buildin testcase stage deliverable.
*
* @access public
* @return void
* @return bool
*/
public function buildinTestcaseStageDeliverable()
public function buildinTestcaseStageDeliverable(): bool
{
$this->app->loadLang('testcase');
$clientLang = $this->app->getClientLang();
@@ -11561,12 +11561,51 @@ class upgradeModel extends model
->fetchPairs();
if(empty($testcaseStageList)) $testcaseStageList = $this->lang->testcase->stageList;
$this->createTestcaseDeliverable($testcaseStageList);
$modules = $this->dao->select('root,id')->from(TABLE_MODULE)
return true;
}
/**
* 创建测试用例阶段类型交付物。
* Create testcase deliverable.
*
* @param array $modules
* @access public
* @return bool
*/
public function createTestcaseDeliverable(array $modules): bool
{
$testModules = $this->dao->select('root,id')->from(TABLE_MODULE)
->where('type')->eq('deliverable')
->andWhere('extra')->eq('test')
->fetchPairs();
$testDeliverable = $this->dao->select('category')->from(TABLE_DELIVERABLE)
->where('buitin')->eq('1')
->andWhere('module')->in($testModules)
->fetchPairs();
/* 已经存在但是被删除的交付物进行还原操作。 */
foreach($modules as $key => $name)
{
if(empty($name)) continue;
if(!empty($testDeliverable[$key]))
{
$this->dao->update(TABLE_DELIVERABLE)->set('deleted')->eq('0')->set('name')->eq($name . $this->lang->upgrade->list)->where('category')->eq($key)->andWhere('buitin')->eq('1')->exec();
unset($modules[$key]);
}
}
$activityList = $this->dao->select('t1.*')->from(TABLE_ACTIVITY)->alias('t1')->leftJoin(TABLE_PROCESS)->alias('t2')->on('t1.process=t2.id')
->where('t1.name')->eq($this->lang->other)
->andWhere('t2.name')->eq($this->lang->other)
->fetchGroup('workflowGroup');
$projectModules = $this->dao->select('root,id')->from(TABLE_MODULE)->where('type')->eq('process')->andWhere('extra')->eq('project')->fetchPairs();
if(empty($modules)) return true;
$deliverable = new stdClass();
$deliverable->status = 'enabled';
$deliverable->createdBy = 'system';
@@ -11581,17 +11620,66 @@ class upgradeModel extends model
$workflows = $this->dao->select('id')->from(TABLE_WORKFLOWGROUP)->where('type')->eq('project')->fetchAll('id');
foreach($workflows as $workflow)
{
$deliverable->module = zget($modules, $workflow->id, 0);
$groupID = $workflow->id;
if(!empty($activityList[$groupID]))
{
$otherActivity = reset($activityList[$groupID]);
$otherActivityID = $otherActivity->id;
}
else
{
if(empty($projectModules[$groupID])) continue;
$otherActivityID = $this->createOtherActivity($projectModules[$groupID], $groupID);
}
$deliverable->module = zget($testModules, $workflow->id, 0);
$deliverable->workflowGroup = $workflow->id;
foreach($testcaseStageList as $key => $name)
$deliverable->activity = $otherActivityID;
foreach($modules as $key => $name)
{
if(empty($name)) continue;
$deliverable->category = $key; // 标记交付物的类型。
$this->addDeliverable($name . $this->lang->upgrade->list, $deliverable, $deliverableStage);
}
}
return true;
}
/**
* 删除测试用例阶段交付物。
* Delete testcase deliverable.
*
* @param array $modules
* @access public
* @return bool
*/
public function deleteTestcaseDeliverable(array $modules): bool
{
foreach($modules as $key => $name)
{
$this->dao->update(TABLE_DELIVERABLE)->set('deleted')->eq('1')->where('category')->eq($key)->andWhere('buitin')->eq('1')->exec();
}
return true;
}
/**
* 变更测试用例阶段交付物名称。
* Change testcase deliverable.
*
* @param array $modules
* @access public
* @return bool
*/
public function changeTestcaseDeliverable(array $modules): bool
{
foreach($modules as $key => $name)
{
$this->dao->update(TABLE_DELIVERABLE)->set('name')->eq($name . $this->lang->upgrade->list)->where('category')->eq($key)->andWhere('buitin')->eq('1')->exec();
}
return true;
}
/**
* 升级项目和迭代的交付物配置。
* Upgrade project deliverable.