\Tests\FeatureMaintainFileApiTest

测试基座(抽象基类)

被测对象:无(公共测试设施) 守护约定:Redis 直连用例在无 Redis 环境(如 CI)跳过而非失败(TEST_REQUIRE_REDIS=1 可强制失败); 缓存注册表最小 schema 供 sqlite :memory: 下凡走注册表的用例自建。

Summary

Methods
Properties
Constants
test_upload_file_creates_record()
test_list_returns_paginated_files()
test_folder_crud_roundtrip()
test_batch_trash_and_restore()
test_purge_trash_clears_physical_and_record()
test_download_shared_file_returns_stream()
test_refs_returns_list()
No public properties found
No constants found
openSession()
authedJson()
cleanupSessionKeys()
requireRedis()
buildCacheRegistry()
setUp()
tearDown()
$md5Key
N/A
openSuperSession()
makeFile()
No private properties found
N/A

Properties

$md5Key

$md5Key : string

当前会话 md5Key(openSession 登记,tearDown 清理)

Type

string

Methods

test_upload_file_creates_record()

test_upload_file_creates_record() : void

上传合法文件:201 + 响应收敛为 id/original_name,落库归属操作者。

test_list_returns_paginated_files()

test_list_returns_paginated_files() : void

列表返回分页结构(list+meta.total)且包含新上传文件。

test_folder_crud_roundtrip()

test_folder_crud_roundtrip() : void

目录全链路:建 → 改 → 删。

test_batch_trash_and_restore()

test_batch_trash_and_restore() : void

批量移入回收站 + 批量恢复:affected 计数正确。

test_purge_trash_clears_physical_and_record()

test_purge_trash_clears_physical_and_record() : void

清空回收站:物理文件与记录一并清理。

test_download_shared_file_returns_stream()

test_download_shared_file_returns_stream() : void

共享文件经 admin 线鉴权下载:200 流式响应。

test_refs_returns_list()

test_refs_returns_list() : void

反向引用清单:返回配置引用结构(空库下为空数组)。

openSession()

openSession(\App\Models\SysUser  $user) : string

建立会话:用户 token_key 指向 md5Key,Redis 存签名 JWT(同 JwtCookieMiddlewareTest 模式)

Parameters

\App\Models\SysUser $user

Returns

string —

authedJson()

authedJson(string  $method, string  $uri, array  $data = []) : \Illuminate\Testing\TestResponse

带认证的请求(call 显式 cookies 走全链路;withCookie 在本项目测试环境失效,勿用)

Parameters

string $method
string $uri
array $data

Returns

\Illuminate\Testing\TestResponse —

cleanupSessionKeys()

cleanupSessionKeys() : void

会话 Redis 键清理(tearDown 调一行;extra 键各测试自理)

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

tearDown()

tearDown() : void

openSuperSession()

openSuperSession() : \App\Models\SysUser

超管用户(PermissionAuthMiddleware 放行一切,专注端点接线与响应契约)

Returns

\App\Models\SysUser —

makeFile()

makeFile(\App\Models\SysUser  $user, array  $attrs = []) : \App\Models\SysFile

造一条文件记录(物理路径随意——上传/下载用例用 fake 盘真实文件)

Parameters

\App\Models\SysUser $user
array $attrs

Returns

\App\Models\SysFile —