\Tests\FeatureLogQueryApiTest

系统日志查询接口

被测对象:logs/login、logs/oper、logs/error 三组路由(controller + service + request) 守护约定:分页 meta 结构;搜索与状态/模块/业务类型筛选命中;详情含堆栈; 处理标记落状态/处理人/备注(非法状态 422);不存在资源 404。

Summary

Methods
Properties
Constants
test_login_log_paginates_and_filters()
test_login_log_show_and_not_found()
test_oper_log_filters_by_module_and_business_type()
test_error_log_filter_detail_and_handle()
test_error_log_show_not_found()
test_oper_log_scoped_to_own_rows()
test_login_log_scoped_to_own_rows()
test_error_log_scoped_to_own_rows()
test_my_oper_logs_own_only_even_for_super()
test_my_login_logs_own_only()
No public properties found
No constants found
requireRedis()
buildCacheRegistry()
setUp()
No protected properties found
N/A
actAsUser()
actAsNormalUser()
No private properties found
N/A

Methods

test_login_log_paginates_and_filters()

test_login_log_paginates_and_filters() : void

登录日志:分页 meta + 状态筛选 + 用户名搜索

test_login_log_show_and_not_found()

test_login_log_show_and_not_found() : void

登录日志:单条详情与 404 兜底

test_oper_log_filters_by_module_and_business_type()

test_oper_log_filters_by_module_and_business_type() : void

操作日志:模块与业务类型筛选 + 参数脱敏后原样回显

test_error_log_filter_detail_and_handle()

test_error_log_filter_detail_and_handle() : void

错误日志:状态筛选 + 详情含堆栈 + 处理标记(状态/处理人/备注)+ 非法状态 422

test_error_log_show_not_found()

test_error_log_show_not_found() : void

错误日志:不存在资源 404

test_oper_log_scoped_to_own_rows()

test_oper_log_scoped_to_own_rows() : void

操作日志:普通用户列表仅见本人行;他人详情 404(不泄露存在性);本人详情正常

test_login_log_scoped_to_own_rows()

test_login_log_scoped_to_own_rows() : void

登录日志:普通用户仅见本人行,匿名失败行(user_id 为空)不可见,他人详情 404

test_error_log_scoped_to_own_rows()

test_error_log_scoped_to_own_rows() : void

错误日志:普通用户仅见本人行(接口级兜底——菜单未对普通角色开放)

test_my_oper_logs_own_only_even_for_super()

test_my_oper_logs_own_only_even_for_super() : void

我的操作:超管也只看到本人行(个人中心语义,不做全量特权);他人详情 404

test_my_login_logs_own_only()

test_my_login_logs_own_only() : void

我的登录:普通用户仅本人行,匿名失败行不可见,搜索在本人行内命中

requireRedis()

requireRedis() : void

Redis 依赖探针:直连 Redis 的测试(限流/会话/验证码)在无 Redis 环境(如 CI) 跳过而非失败——其余用例不受影响。CI 可设 TEST_REQUIRE_REDIS=1 强制模式: Redis 不可达即失败而非跳过,安全回归套件不允许静默消失。

buildCacheRegistry()

buildCacheRegistry(array  $items) : void

建缓存注册表最小 schema(td_sys_cache)并灌入注册项。

测试跑 sqlite :memory:,生产迁移含 PostgreSQL 专属 DDL 跑不通(DataScopeServiceTest 同因自建 schema); 而 CacheManager::registry() 现已从数据库表读取——凡走注册表的测试(remember/get/key/失效推导) 必须在 setUp 先调用本方法,否则注册表为空、remember 未登记名会走「自动登记」路径。

Parameters

array $items

setUp()

setUp() : void

建日志表最小 schema 并注册被测路由(sqlite :memory: 自建,与生产迁移列对齐)

actAsUser()

actAsUser() : \App\Models\SysUser

构造已登录测试用户(超管:可见全部日志行,既有全量用例的前提;处理人取 real_name)

Returns

\App\Models\SysUser —

actAsNormalUser()

actAsNormalUser(int  $id = 2, string  $realName = '普通用户') : \App\Models\SysUser

构造普通登录用户(is_super=0:仅可见本人日志行)

Parameters

int $id
string $realName

Returns

\App\Models\SysUser —