+ [misc] Add unit tests for convertTao::buildCustomFieldOptionData() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1816,4 +1816,30 @@ class convertTest
|
||||
return 'error: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildCustomFieldOptionData method.
|
||||
*
|
||||
* @param array $data
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function buildCustomFieldOptionDataTest($data = array())
|
||||
{
|
||||
try {
|
||||
// 使用反射来访问protected方法
|
||||
$reflection = new ReflectionClass($this->objectTao);
|
||||
$method = $reflection->getMethod('buildCustomFieldOptionData');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->objectTao, $data);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
return 'exception: ' . $e->getMessage();
|
||||
} catch (Error $e) {
|
||||
return 'error: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 convertTao::buildCustomFieldOptionData();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 步骤1:正常自定义字段选项数据转换 - ID属性id @1001
|
||||
- 步骤1:正常自定义字段选项数据转换 - customfield属性customfield @1
|
||||
- 步骤1:正常自定义字段选项数据转换 - customfieldconfig属性customfieldconfig @2
|
||||
- 步骤1:正常自定义字段选项数据转换 - customvalue属性customvalue @Option A
|
||||
- 步骤1:正常自定义字段选项数据转换 - disabled属性disabled @0
|
||||
|
||||
*/
|
||||
|
||||
// 1. 导入依赖(路径固定,不可修改)
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/convert.unittest.class.php';
|
||||
|
||||
// 2. 用户登录(选择合适角色)
|
||||
su('admin');
|
||||
|
||||
// 3. 创建测试实例(变量名与模块名一致)
|
||||
$convertTest = new convertTest();
|
||||
|
||||
// 4. 必须包含至少5个测试步骤
|
||||
r($convertTest->buildCustomFieldOptionDataTest(array('id' => '1001', 'customfield' => '1', 'customfieldconfig' => '2', 'value' => 'Option A', 'disabled' => '0'))) && p('id') && e('1001'); // 步骤1:正常自定义字段选项数据转换 - ID
|
||||
r($convertTest->buildCustomFieldOptionDataTest(array('id' => '1001', 'customfield' => '1', 'customfieldconfig' => '2', 'value' => 'Option A', 'disabled' => '0'))) && p('customfield') && e('1'); // 步骤1:正常自定义字段选项数据转换 - customfield
|
||||
r($convertTest->buildCustomFieldOptionDataTest(array('id' => '1001', 'customfield' => '1', 'customfieldconfig' => '2', 'value' => 'Option A', 'disabled' => '0'))) && p('customfieldconfig') && e('2'); // 步骤1:正常自定义字段选项数据转换 - customfieldconfig
|
||||
r($convertTest->buildCustomFieldOptionDataTest(array('id' => '1001', 'customfield' => '1', 'customfieldconfig' => '2', 'value' => 'Option A', 'disabled' => '0'))) && p('customvalue') && e('Option A'); // 步骤1:正常自定义字段选项数据转换 - customvalue
|
||||
r($convertTest->buildCustomFieldOptionDataTest(array('id' => '1001', 'customfield' => '1', 'customfieldconfig' => '2', 'value' => 'Option A', 'disabled' => '0'))) && p('disabled') && e('0'); // 步骤1:正常自定义字段选项数据转换 - disabled
|
||||
Reference in New Issue
Block a user