feat: 教練審核流程完整版——四狀態機、證照送審、Admin 裁決、通知(含測試清空 DB 重大修復) #36

Merged
a620906209 merged 2 commits from feat/provider-verification-workflow into master 2026-06-11 19:40:53 +00:00
Owner

摘要

實作 openspec change provider-verification-workflow(25/25 tasks,路線圖第一優先項目),加上一個過程中抓到的重大測試基礎設施修復

🔴 重大修復(commit 3714055,建議先看)

容器內每次跑測試都在清空開發用 MySQL——docker compose 把 DB_CONNECTION=mysql 注入為真實環境變數(存在 $_SERVER),PHPUnit 的 <env force> 只覆蓋 $_ENV/putenv,而 Laravel env() 優先讀 $_SERVER → RefreshDatabase 一直打在真 DB 上。這就是先前兩次「DB 神秘清空」的元凶。修法:tests/bootstrap.php 在載入前三者同步強制 sqlite。已驗證全套件跑完 MySQL 資料存活。

教練審核流程

狀態機unsubmitted →(送審)→ pending →(裁決)→ approved / rejected →(重送)→ pending,approved 可被撤銷(原因必填)。is_verified boolean 移除,migration 自動轉換,API 以 accessor 保留相容輸出。

教練端/coach/verification 新頁):證照上傳 ≤3 張(複用 CompressesImages 壓縮)、送審、駁回原因顯示、重新送審;pending/approved 期間證照鎖定(審核依據不可變)。

Admin 端:審核佇列(待審 filter)、查看證照、通過/駁回(原因必填並通知);移除 toggle-verified 端點(單鍵切換可繞過狀態機)。

通知:審核結果站內+Email,駁回含原因。

政策延續:可見性與預約入口改判 approved(行為等價);既有預約不受狀態變動影響。

驗證

  • 容器內全套件 174 passed / 440 assertions(新增 18 條驗證測試)
  • Demo 資料:第 4 位教練為 pending(展示審核佇列)

部署注意

  • 有 migration(is_verified 轉換 + 新表 provider_certifications),部署會自動跑
  • 前端有改動,需 rebuild frontend image
  • Admin 後台的「驗證/取消驗證」按鈕已改為「通過/駁回」審核流
  • merge 後 openspec change 可歸檔

🤖 Generated with Claude Code

## 摘要 實作 openspec change `provider-verification-workflow`(25/25 tasks,路線圖第一優先項目),加上一個過程中抓到的**重大測試基礎設施修復**。 ## 🔴 重大修復(commit 3714055,建議先看) **容器內每次跑測試都在清空開發用 MySQL**——docker compose 把 `DB_CONNECTION=mysql` 注入為真實環境變數(存在 `$_SERVER`),PHPUnit 的 `<env force>` 只覆蓋 `$_ENV`/putenv,而 Laravel `env()` 優先讀 `$_SERVER` → RefreshDatabase 一直打在真 DB 上。這就是先前兩次「DB 神秘清空」的元凶。修法:`tests/bootstrap.php` 在載入前三者同步強制 sqlite。已驗證全套件跑完 MySQL 資料存活。 ## 教練審核流程 **狀態機**:`unsubmitted →(送審)→ pending →(裁決)→ approved / rejected →(重送)→ pending`,approved 可被撤銷(原因必填)。`is_verified` boolean 移除,migration 自動轉換,API 以 accessor 保留相容輸出。 **教練端**(`/coach/verification` 新頁):證照上傳 ≤3 張(複用 CompressesImages 壓縮)、送審、駁回原因顯示、重新送審;pending/approved 期間證照鎖定(審核依據不可變)。 **Admin 端**:審核佇列(待審 filter)、查看證照、通過/駁回(原因必填並通知);**移除 toggle-verified 端點**(單鍵切換可繞過狀態機)。 **通知**:審核結果站內+Email,駁回含原因。 **政策延續**:可見性與預約入口改判 `approved`(行為等價);既有預約不受狀態變動影響。 ## 驗證 - 容器內全套件 **174 passed / 440 assertions**(新增 18 條驗證測試) - Demo 資料:第 4 位教練為 pending(展示審核佇列) ## 部署注意 - **有 migration**(is_verified 轉換 + 新表 provider_certifications),部署會自動跑 - **前端有改動**,需 rebuild frontend image - Admin 後台的「驗證/取消驗證」按鈕已改為「通過/駁回」審核流 - merge 後 openspec change 可歸檔 🤖 Generated with [Claude Code](https://claude.com/claude-code)
a620906209 added 2 commits 2026-06-11 16:26:44 +00:00
根因:docker compose 將 DB_CONNECTION=mysql 注入為真實環境變數,
PHPUnit 的 <env force> 只覆蓋 $_ENV/putenv,但 Laravel env() 優先讀
$_SERVER,導致 RefreshDatabase 一直在清空開發 DB(今日實際發生三次,
也是先前『DB 神秘清空』的元凶)。

- 新增 tests/bootstrap.php 於載入前同步覆蓋 $_SERVER/$_ENV/putenv
- phpunit.xml bootstrap 指向新檔,DB env 加 force 屬性
- 驗證:容器內全套件後 MySQL 資料存活(users=13)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
實作 openspec change provider-verification-workflow(25/25 tasks):
- is_verified 升級為 verification_status 四狀態機(unsubmitted/pending/
  approved/rejected),migration 自動轉換既有資料,API 以 accessor 保留
  is_verified 相容輸出
- 教練端:證照上傳(≤3 張、複用 CompressesImages)、送審、駁回原因
  顯示與重送(/coach/verification 新頁面)
- Admin 端:審核佇列、通過/駁回(原因必填)、撤銷 approved;移除
  toggle-verified 端點(防繞過狀態機);裁決後 flush 課程快取
- 通知:審核通過/駁回(站內+Email,駁回含原因)
- 可見性與預約入口改判 approved(行為等價)
- 測試 +18(ProviderVerificationTest 10、AdminVerificationTest 8),
  既有 4 個測試檔 helper 遷移;Swagger 同步
- 規格同步:provider-verification 全面改寫、admin-user-management
  toggle 段落改為移除聲明

容器內全套件 173 passed / 439 assertions。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
a620906209 merged commit e40507bd60 into master 2026-06-11 19:40:53 +00:00
a620906209 deleted branch feat/provider-verification-workflow 2026-06-11 19:40:53 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: a620906209/CFDivePlatform#36