diff --git a/module/ai/test/lib/ai.unittest.class.php b/module/ai/test/lib/ai.unittest.class.php index 1229191c45..2000da5ea2 100644 --- a/module/ai/test/lib/ai.unittest.class.php +++ b/module/ai/test/lib/ai.unittest.class.php @@ -308,4 +308,23 @@ class aiTest return $result; } + + /** + * Test standardizeParams method. + * + * @param mixed $data + * @access public + * @return mixed + */ + public function standardizeParamsTest($data = null) + { + /* Using reflection to call private static method */ + $reflection = new ReflectionClass($this->objectModel); + $method = $reflection->getMethod('standardizeParams'); + $method->setAccessible(true); + $result = $method->invoke(null, $data); + if(dao::isError()) return dao::getError(); + + return $result; + } } \ No newline at end of file diff --git a/module/ai/test/model/standardizeparams.php b/module/ai/test/model/standardizeparams.php new file mode 100755 index 0000000000..caa94d4111 --- /dev/null +++ b/module/ai/test/model/standardizeparams.php @@ -0,0 +1,55 @@ +#!/usr/bin/env php +camelCaseProperty = 'value1'; +$normalData->anotherCamelCase = 'value2'; +r($aiTest->standardizeParamsTest($normalData)) && p('camel_case_property,another_camel_case') && e('value1,value2'); // 步骤1:正常对象参数转换 + +// 步骤2:空对象参数处理 - 检查属性数量 +$emptyData = new stdClass(); +$result2 = $aiTest->standardizeParamsTest($emptyData); +r(count(get_object_vars($result2))) && p() && e(0); // 步骤2:空对象参数处理 + +// 步骤3:单个属性对象转换 +$singleData = new stdClass(); +$singleData->userName = 'test'; +r($aiTest->standardizeParamsTest($singleData)) && p('user_name') && e('test'); // 步骤3:单个属性对象转换 + +// 步骤4:包含数字的属性转换 +$numberData = new stdClass(); +$numberData->property123Name = 'number'; +r($aiTest->standardizeParamsTest($numberData)) && p('property123_name') && e('number'); // 步骤4:包含数字的属性转换 + +// 步骤5:复杂驼峰命名转换 +$complexData = new stdClass(); +$complexData->veryLongPropertyNameWithManyWords = 'complex'; +r($aiTest->standardizeParamsTest($complexData)) && p('very_long_property_name_with_many_words') && e('complex'); // 步骤5:复杂驼峰命名转换 \ No newline at end of file