From 71ba733de718ff1aaf4f44428dcd3acd8d8c1083 Mon Sep 17 00:00:00 2001 From: liyang Date: Mon, 7 Jul 2025 15:13:36 +0800 Subject: [PATCH] + [unittest] add init Reference method. --- test/lib/init.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/lib/init.php b/test/lib/init.php index 2dd90fe794..6466672714 100644 --- a/test/lib/init.php +++ b/test/lib/init.php @@ -314,3 +314,33 @@ function su($account, $initRights = true) return true; } + +/** + * 初始化反射类。 + * Initialize reflection class. + * + * @param int $moduleName + * @param string $type + * @access public + * @return bool|ReflectionClass + */ +function initReference($moduleName, $type = 'zen') +{ + global $tester; + helper::import($tester->app->getModulePath('', $moduleName) . 'control.php'); + $tester->app->control = new $moduleName(); + $class = ''; + if($type == 'zen') + { + helper::import($tester->app->getModulePath('', $moduleName) . 'zen.php'); + $class = $moduleName . 'Zen'; + } + else + { + helper::import($tester->app->getModulePath('', $moduleName) . 'model.php'); + $class = $moduleName . 'Model'; + } + + if(!$class || !class_exists($class)) return false; + return new ReflectionClass($class); +}