+ [misc] Add unit tests for blockZen::getAvailableParams() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 blockZen::getAvailableParams();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行blockTest模块的getAvailableParamsTest方法,参数是'', 'task' 第type条的name属性 @类型
|
||||
- 执行blockTest模块的getAvailableParamsTest方法,参数是'', 'bug' 第type条的name属性 @类型
|
||||
- 执行blockTest模块的getAvailableParamsTest方法,参数是'', 'story' 第type条的name属性 @类型
|
||||
- 执行blockTest模块的getAvailableParamsTest方法,参数是'', 'nonexistent' @0
|
||||
- 执行blockTest模块的getAvailableParamsTest方法,参数是'assigntome', 'todo' 第count条的name属性 @数量
|
||||
- 执行blockTest模块的getAvailableParamsTest方法,参数是'product', 'statistic' 第type条的name属性 @类型
|
||||
- 执行blockTest模块的getAvailableParamsTest方法,参数是'assigntome', 'list' 第count条的name属性 @数量
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/block.unittest.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$blockTest = new blockTest();
|
||||
|
||||
r($blockTest->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('数量');
|
||||
Reference in New Issue
Block a user