+ [misc] Add unit tests for dataviewModel::processMergeFields() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-15 15:06:14 +08:00
co-authored by Claude
parent fdace1a88e
commit 31dc97d43a
2 changed files with 55 additions and 0 deletions
@@ -67,4 +67,22 @@ class dataviewTest
return array('result' => 'fail', 'message' => $e->getMessage());
}
}
/**
* Test processMergeFields method.
*
* @param string $moduleName
* @param string $field
* @param string $fieldName
* @param array $workflowFields
* @access public
* @return mixed
*/
public function processMergeFieldsTest($moduleName, $field, $fieldName, $workflowFields = array())
{
$result = $this->objectModel->processMergeFields($moduleName, $field, $fieldName, $workflowFields);
if(dao::isError()) return dao::getError();
return $result;
}
}
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env php
<?php
/**
title=测试 dataviewModel::processMergeFields();
timeout=0
cid=0
- 执行dataviewTest模块的processMergeFieldsTest方法,参数是'user', 'account', 'account', array
- @用户名
- 属性1 @user
- 执行dataviewTest模块的processMergeFieldsTest方法,参数是'flow_project', 'name', 'name', array
- @项目名称
- 属性1 @project
- 执行dataviewTest模块的processMergeFieldsTest方法,参数是'zt_flow_task', 'title', 'title', array
- @title
- 属性1 @task
- 执行dataviewTest模块的processMergeFieldsTest方法,参数是'product', 'nonexistfield', 'nonexistfield', array
- @nonexistfield
- 属性1 @product
- 执行dataviewTest模块的processMergeFieldsTest方法,参数是'task', '', '', array @~~
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/dataview.unittest.class.php';
su('admin');
$dataviewTest = new dataviewTest();
r($dataviewTest->processMergeFieldsTest('user', 'account', 'account', array())) && p('0,1') && e('用户名,user');
r($dataviewTest->processMergeFieldsTest('flow_project', 'name', 'name', array())) && p('0,1') && e('项目名称,project');
r($dataviewTest->processMergeFieldsTest('zt_flow_task', 'title', 'title', array())) && p('0,1') && e('title,task');
r($dataviewTest->processMergeFieldsTest('product', 'nonexistfield', 'nonexistfield', array())) && p('0,1') && e('nonexistfield,product');
r($dataviewTest->processMergeFieldsTest('task', '', '', array())) && p('0') && e('~~');