* Refactor transfer model: commonActions method.

This commit is contained in:
tanghucheng
2023-12-15 03:58:42 -05:00
parent f99ef9c117
commit 396f928fa0
3 changed files with 76 additions and 7 deletions
+8 -7
View File
@@ -45,13 +45,14 @@ class transferModel extends model
}
/**
* Common Actions.
* Transfer 公共方法(格式化模块语言项,Config,字段)。
* Common actions.
*
* @param int $module
* @access public
* @return void
*/
public function commonActions($module = '')
public function commonActions(string $module = '')
{
if($module)
{
@@ -519,14 +520,14 @@ class transferModel extends model
* Get field values by method.
*
* @param int $module
* @param int $module
* @param int $callModule
* @param int $method
* @param string $params
* @param string $pairs
* @access public
* @return void
*/
public function getSourceByModuleMethod($module, $module, $method, $params = '', $pairs = '')
public function getSourceByModuleMethod($module, $callModule, $method, $params = '', $pairs = '')
{
$getParams = $this->session->{$module . 'TransferParams'};
@@ -542,15 +543,15 @@ class transferModel extends model
/* If this method has multiple parameters use call_user_func_array. */
if(is_array($params))
{
$values = call_user_func_array(array($this->loadModel($module), $method), $params);
$values = call_user_func_array(array($this->loadModel($callModule), $method), $params);
}
elseif($params)
{
$values = $this->loadModel($module)->$method($params);
$values = $this->loadModel($callModule)->$method($params);
}
else
{
$values = $this->loadModel($module)->$method();
$values = $this->loadModel($callModule)->$method();
}
if(!empty($pairs))
@@ -0,0 +1,35 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/transfer.class.php';
su('admin');
/**
title=测试 transfer->commonActions();
timeout=0
cid=1
- 测试获取Task模块创建的必填字段第execution条的title属性 @execution
- 测试获取Task模块legendEffort语言项属性legendEffort @工时信息
- 测试获取Task模块report下charts:tasksPerModule语言项第charts条的tasksPerModule属性 @按模块任务数统计
- 测试获取Task模块创建的必填字段
- 第id条的title属性 @ID
- 第status条的title属性 @状态
*/
global $tester;
$transfer = $tester->loadModel('transfer');
/* 获取Task模块配置信息。*/
/* Get Task module config information. */
$transfer->commonActions('task');
$moduleConfig = $transfer->moduleConfig->dtable->fieldList;
$moduleLang = $transfer->moduleLang;
$moduleFieldList = $transfer->moduleFieldList;
r($moduleConfig) && p('execution:title') && e('execution'); // 测试获取Task模块创建的必填字段
r($moduleLang) && p('legendEffort') && e('工时信息'); // 测试获取Task模块legendEffort语言项
r($moduleLang->report) && p('charts:tasksPerModule') && e('按模块任务数统计'); // 测试获取Task模块report下charts:tasksPerModule语言项
r($moduleFieldList) && p('id:title;status:title') && e('ID;状态'); // 测试获取Task模块创建的必填字段
+33
View File
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
/**
* The zen file of transfer module of ZenTaoPMS.
*
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Tang Hucheng<tanghucheng@easycorp.ltd>
* @package transfer
* @link https://www.zentao.net
*/
class transferTest
{
public function __construct()
{
global $tester;
$this->objectModel = $tester->loadModel('transfer');
}
/**
* 测试通过 id 获取用例库信息。
* Get by ID test.
*
* @param bool $setImgSize
* @access public
* @return void
*/
public function commonActionsTest(string $module)
{
$this->objectModel->commonActions($module);
}
}