diff --git a/module/block/test/lib/block.unittest.class.php b/module/block/test/lib/block.unittest.class.php index ecbe01680a..d53f4650ae 100644 --- a/module/block/test/lib/block.unittest.class.php +++ b/module/block/test/lib/block.unittest.class.php @@ -940,4 +940,39 @@ class blockTest return $result; } + + /** + * Test getAvailableParams method in zen layer. + * + * @param string $module + * @param string $code + * @access public + * @return array + */ + public function getAvailableParamsTest(string $module, string $code) + { + global $tester; + + include_once dirname(__FILE__, 3) . '/model.php'; + + if (!class_exists('block')) { + class_alias('blockModel', 'block'); + } + + include_once dirname(__FILE__, 3) . '/zen.php'; + + $blockZen = new blockZen(); + $blockZen->block = $this->objectModel; + + // 使用反射访问受保护的方法 + $reflection = new ReflectionClass($blockZen); + $method = $reflection->getMethod('getAvailableParams'); + $method->setAccessible(true); + + $result = $method->invoke($blockZen, $module, $code); + + if(dao::isError()) return dao::getError(); + + return $result; + } } diff --git a/module/block/test/zen/getavailableparams.php b/module/block/test/zen/getavailableparams.php new file mode 100755 index 0000000000..5910202a61 --- /dev/null +++ b/module/block/test/zen/getavailableparams.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +getAvailableParamsTest('', 'task')) && p('type:name') && e('类型'); +r($blockTest->getAvailableParamsTest('', 'bug')) && p('type:name') && e('类型'); +r($blockTest->getAvailableParamsTest('', 'story')) && p('type:name') && e('类型'); +r($blockTest->getAvailableParamsTest('', 'nonexistent')) && p() && e('0'); +r($blockTest->getAvailableParamsTest('assigntome', 'todo')) && p('count:name') && e('数量'); +r($blockTest->getAvailableParamsTest('product', 'statistic')) && p('type:name') && e('类型'); +r($blockTest->getAvailableParamsTest('assigntome', 'list')) && p('count:name') && e('数量'); \ No newline at end of file