From 396f928fa0bcf66f55404565c36645a66ef356ab Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Fri, 15 Dec 2023 03:57:20 -0500 Subject: [PATCH] * Refactor transfer model: commonActions method. --- module/transfer/model.php | 15 +++++---- module/transfer/test/model/commonactions.php | 35 ++++++++++++++++++++ module/transfer/test/transfer.class.php | 33 ++++++++++++++++++ 3 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 module/transfer/test/model/commonactions.php create mode 100644 module/transfer/test/transfer.class.php diff --git a/module/transfer/model.php b/module/transfer/model.php index 364748ee7b..24f28c2e62 100644 --- a/module/transfer/model.php +++ b/module/transfer/model.php @@ -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)) diff --git a/module/transfer/test/model/commonactions.php b/module/transfer/test/model/commonactions.php new file mode 100644 index 0000000000..5aa797b997 --- /dev/null +++ b/module/transfer/test/model/commonactions.php @@ -0,0 +1,35 @@ +#!/usr/bin/env php +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模块创建的必填字段 diff --git a/module/transfer/test/transfer.class.php b/module/transfer/test/transfer.class.php new file mode 100644 index 0000000000..67e61f3adf --- /dev/null +++ b/module/transfer/test/transfer.class.php @@ -0,0 +1,33 @@ + + * @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); + } +}