diff --git a/module/common/test/lib/common.unittest.class.php b/module/common/test/lib/common.unittest.class.php index 9ed2bbcfa0..3714d6454c 100644 --- a/module/common/test/lib/common.unittest.class.php +++ b/module/common/test/lib/common.unittest.class.php @@ -1817,6 +1817,57 @@ class commonTest } } + /** + * Test printModuleMenu method. + * + * @param string $activeMenu + * @access public + * @return mixed + */ + public function printModuleMenuTest($activeMenu = 'user') + { + global $app, $lang; + + // Mock basic global variables if not set + if (!isset($app)) + { + $app = new stdClass(); + $app->rawModule = 'user'; + $app->rawMethod = 'browse'; + $app->tab = 'system'; + $app->viewType = 'html'; + $app->isFlow = false; + } + + if (!isset($lang)) + { + $lang = new stdClass(); + } + + // Set up basic tab menu structure + if (!isset($lang->{$app->tab})) + { + $lang->{$app->tab} = new stdClass(); + } + if (!isset($lang->{$app->tab}->menu)) + { + $lang->{$app->tab}->menu = new stdClass(); + } + + ob_start(); + try { + commonModel::printModuleMenu($activeMenu); + $result = ob_get_clean(); + } catch (Exception $e) { + ob_end_clean(); + return 'Exception: ' . $e->getMessage(); + } + + if(dao::isError()) return dao::getError(); + + return $result; + } + /** * Test printMainMenu method. * diff --git a/module/common/test/model/printmodulemenu.php b/module/common/test/model/printmodulemenu.php new file mode 100755 index 0000000000..2aedd0ac9a --- /dev/null +++ b/module/common/test/model/printmodulemenu.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +isStatic() ? '1' : '0') && p() && e('1'); // 验证为静态方法 +r($reflection->isPublic() ? '1' : '0') && p() && e('1'); // 验证为公共方法 +r($reflection->getNumberOfParameters()) && p() && e('1'); // 验证参数个数 +r($reflection->hasReturnType() ? '1' : '0') && p() && e('0'); // 验证无返回类型(void类型) \ No newline at end of file