\Tests\FeatureMyFilesApiTest

测试基座(抽象基类)

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

Summary

Methods
Properties
Constants
test_list_only_returns_own_files()
test_operate_other_file_rejected()
test_download_other_file_rejected()
test_trash_own_file()
test_restore_own_file()
test_purge_trash_only_own()
test_scenes_endpoint_available_without_permission_code()
test_download_other_shared_file_allowed()
No public properties found
No constants found
openSession()
authedJson()
cleanupSessionKeys()
requireRedis()
buildCacheRegistry()
setUp()
tearDown()
$md5Key
N/A
makeUser()
makeFile()
No private properties found
N/A

Properties

$md5Key

$md5Key : string

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

Type

string

Methods

test_list_only_returns_own_files()

test_list_only_returns_own_files() : void

列表仅返回本人文件(他人文件不出现——豁免同规)

test_operate_other_file_rejected()

test_operate_other_file_rejected() : void

他人文件操作一律拒绝(改名 400)——个人中心无越权面

test_download_other_file_rejected()

test_download_other_file_rejected() : void

他人文件下载拒绝

test_trash_own_file()

test_trash_own_file() : void

本人文件可移入回收站并从列表消失

test_restore_own_file()

test_restore_own_file() : void

回收站列表仅本人 + 恢复

test_purge_trash_only_own()

test_purge_trash_only_own() : void

清空回收站仅作用于本人

test_scenes_endpoint_available_without_permission_code()

test_scenes_endpoint_available_without_permission_code() : void

场景清单走认证线:任何登录用户可用(无 sys:file:read 权限码),含内置 default 场景

test_download_other_shared_file_allowed()

test_download_other_shared_file_allowed() : void

他人共享文件(avatar 场景自动共享,可能由管理员代传)可经 my 线下载;私有文件仍拒绝

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

makeUser()

makeUser() : \App\Models\SysUser

Returns

\App\Models\SysUser —

makeFile()

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

造一条文件记录(本人/他人可指定;物理路径随意——接口不读盘)

Parameters

\App\Models\SysUser $user
array $attrs

Returns

\App\Models\SysFile —