From zenbu-powers
處理 When 步驟中執行讀取操作(Query)的 handler 參考文件。觸發關鍵字:查詢、取得、列出、搜尋。 非 user-invocable,由 /aibdd.auto.php.it.red 在實作測試方法時載入。
npx claudepluginhub zenbuapps/zenbu-powers --plugin zenbu-powersThis skill uses the workspace's default tool permissions.
本 handler 適用於 **When** 步驟中的讀取操作:
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Guides code writing, review, and refactoring with Karpathy-inspired rules to avoid overcomplication, ensure simplicity, surgical changes, and verifiable success criteria.
Share bugs, ideas, or general feedback.
本 handler 適用於 When 步驟中的讀取操作:
關鍵字:查詢、取得、列出、搜尋、檢視、讀取
呼叫 Service 的讀取方法,將結果存入 $this->queryResult,供後續 Then 步驟驗證。必須 try/catch,錯誤仍存入 $this->lastError(可能的 Query 失敗情境如權限不足)。
| 項目 | Query | Command |
|---|---|---|
| 修改系統狀態 | 否 | 是 |
| Service 方法前綴 | get、find、list、search | create、update、delete、submit |
| 結果儲存 | $this->queryResult | 無(不驗證回傳) |
| Then 對應 handler | readmodel-then | aggregate-then / success-failure |
$this->ids 取得查詢主體 ID:$userId = $this->ids['Alice'];$this->queryResult。$this->queryResult = null,錯誤存入 $this->lastError。When 用戶 "Alice" 查詢課程 1 的進度
$userId = $this->ids['Alice'];
try {
$this->queryResult = $this->services->lesson->getProgress($userId, 1);
} catch (\Throwable $e) {
$this->lastError = $e;
$this->queryResult = null;
}
When 用戶 "Alice" 查詢購物車中的所有商品
$userId = $this->ids['Alice'];
try {
$this->queryResult = $this->services->cart->listItems($userId);
} catch (\Throwable $e) {
$this->lastError = $e;
$this->queryResult = null;
}
When 用戶 "Alice" 查詢第 1 章的所有課程
$userId = $this->ids['Alice'];
try {
$this->queryResult = $this->services->lesson->listByChapter($userId, chapterId: 1);
} catch (\Throwable $e) {
$this->lastError = $e;
$this->queryResult = null;
}
When 用戶 "Alice" 搜尋關鍵字 "React" 的課程
$userId = $this->ids['Alice'];
try {
$this->queryResult = $this->services->course->search(
keyword: 'React',
userId: $userId,
);
} catch (\Throwable $e) {
$this->lastError = $e;
$this->queryResult = null;
}
When 用戶 "Alice" 查詢第 2 頁的訂單(每頁 10 筆)
$userId = $this->ids['Alice'];
try {
$this->queryResult = $this->services->order->listByUser(
userId: $userId,
page: 2,
perPage: 10,
);
} catch (\Throwable $e) {
$this->lastError = $e;
$this->queryResult = null;
}
abstract class IntegrationTestCase extends \Yoast\WPTestUtils\WPIntegration\TestCase
{
protected ?\Throwable $lastError = null;
protected mixed $queryResult = null; // ← Query 結果存這裡
protected array $ids = [];
protected object $repos;
protected object $services;
abstract protected function configure_dependencies(): void;
public function set_up(): void {
parent::set_up();
$this->lastError = null;
$this->queryResult = null;
$this->ids = [];
$this->repos = new \stdClass();
$this->services = new \stdClass();
$this->configure_dependencies();
}
}
createXxx、updateXxx、deleteXxx。$this->queryResult,為後續 readmodel-then 使用。$this->queryResult = null 且 $this->lastError = $e;供 success-failure 驗證錯誤。getXxx、listXxx、findXxx、searchXxx)。$this->queryResult。$this->queryResult$this->lastError$this->ids 或 Gherkin 實值取得