make phpunit run inside framework

This commit is contained in:
sunxyw
2022-03-29 00:46:17 +08:00
committed by Jerry Ma
parent 9f4b5fb14a
commit 05a3d0111b
6 changed files with 70 additions and 25 deletions

View File

@@ -82,6 +82,7 @@ class AnnotationParser
$this->reader = new DualReader(new AnnotationReader(), new AttributeReader());
foreach ($all_class as $v) {
Console::debug('正在检索 ' . $v);
$reflection_class = new ReflectionClass($v);
$methods = $reflection_class->getMethods(ReflectionMethod::IS_PUBLIC);
$class_annotations = $this->reader->getClassAnnotations($reflection_class);

View File

@@ -92,6 +92,23 @@ class ZMUtil
foreach ($files as $v) {
$pathinfo = pathinfo($v);
if (($pathinfo['extension'] ?? '') == 'php') {
$path = rtrim($dir, '/') . '/' . rtrim($pathinfo['dirname'], './') . '/' . $pathinfo['basename'];
// 过滤不包含类的文件
$tokens = token_get_all(file_get_contents($path));
$found = false;
foreach ($tokens as $token) {
if (!is_array($token)) {
continue;
}
if ($token[0] === T_CLASS) {
$found = true;
}
}
if (!$found) {
continue;
}
if ($rule === null) { // 规则未设置回调时候,使用默认的识别过滤规则
/*if (substr(file_get_contents($dir . '/' . $v), 6, 6) == '#plain') {
continue;

View File

@@ -12,6 +12,7 @@ use ZM\Exception\InitException;
use ZM\Utils\DataProvider;
use ZM\Utils\ZMUtil;
return;
require_once((!is_dir(__DIR__ . '/../../vendor')) ? getcwd() : (__DIR__ . '/../..')) . '/vendor/autoload.php';
try {