\Tests\FeatureMaintainOrganizationServiceTest

组织维护服务回归

被测对象:destroyCompany / updateDept / destroyDept 守护约定:① 有部门/范围引用的公司不可删 ② 部门不可跨组织移动、不可自引用 ③ 有子部门/任职/岗位的部门不可删 ④ 删除部门级联清范围引用行。

Summary

Methods
Properties
Constants
test_destroy_company_with_depts_rejected()
test_destroy_company_referenced_by_post_scope_rejected()
test_destroy_empty_company_succeeds()
test_update_dept_across_company_rejected()
test_update_dept_self_parent_rejected()
test_update_dept_move_recomputes_ancestors()
test_destroy_dept_with_children_rejected()
test_destroy_dept_with_users_rejected()
test_destroy_dept_with_posts_rejected()
test_destroy_clean_dept_cascades_scope_rows()
No public properties found
No constants found
requireRedis()
buildCacheRegistry()
setUp()
No protected properties found
N/A
makeCompany()
$service
N/A

Properties

Methods

test_destroy_company_with_depts_rejected()

test_destroy_company_with_depts_rejected() : void

公司下有部门:拒绝删除

test_destroy_company_referenced_by_post_scope_rejected()

test_destroy_company_referenced_by_post_scope_rejected() : void

公司被岗位范围引用:拒绝删除(防孤儿范围行)

test_destroy_empty_company_succeeds()

test_destroy_empty_company_succeeds() : void

干净公司:删除成功

test_update_dept_across_company_rejected()

test_update_dept_across_company_rejected() : void

跨组织移动:拒绝(跨组织移动会留脏 ancestors)

test_update_dept_self_parent_rejected()

test_update_dept_self_parent_rejected() : void

自己为父:拒绝

test_update_dept_move_recomputes_ancestors()

test_update_dept_move_recomputes_ancestors() : void

合法移动:父级变更后自身与后代 ancestors 级联重算

test_destroy_dept_with_children_rejected()

test_destroy_dept_with_children_rejected() : void

有子部门:拒绝删除

test_destroy_dept_with_users_rejected()

test_destroy_dept_with_users_rejected() : void

有任职用户:拒绝删除

test_destroy_dept_with_posts_rejected()

test_destroy_dept_with_posts_rejected() : void

有岗位:拒绝删除(岗位唯一归属部门,防岗位孤儿)

test_destroy_clean_dept_cascades_scope_rows()

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

makeCompany()

makeCompany() : \App\Models\SysCompany

Returns

\App\Models\SysCompany —