\Tests\FeatureDeptCodeUniqueTest

部门编码组织内唯一

被测对象:td_sys_dept 的 (company_id, dept_code) 部分唯一索引 守护约定:同公司同编码落库失败;跨公司同编码允许;空编码(未填)不参与约束。

Summary

Methods
Properties
Constants
test_same_company_same_code_is_rejected()
test_same_code_across_companies_is_allowed()
test_empty_codes_are_exempt_from_constraint()
No public properties found
No constants found
requireRedis()
buildCacheRegistry()
No protected properties found
N/A
makeDept()
No private properties found
N/A

Methods

test_same_company_same_code_is_rejected()

test_same_company_same_code_is_rejected() : void

同公司同编码的第二行被唯一索引拒绝。

test_same_code_across_companies_is_allowed()

test_same_code_across_companies_is_allowed() : void

跨公司同编码允许(约束粒度 = 组织内)。

test_empty_codes_are_exempt_from_constraint()

test_empty_codes_are_exempt_from_constraint() : 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

makeDept()

makeDept(int  $companyId, string  $code, string  $name) : \App\Models\SysDept

Parameters

int $companyId
string $code
string $name

Returns

\App\Models\SysDept —