一键导入
pest-testing
SDLC Phase: TESTING. Test writing, editing, and fixing using Pest — feature tests, unit tests, architecture tests, Livewire component tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
SDLC Phase: TESTING. Test writing, editing, and fixing using Pest — feature tests, unit tests, architecture tests, Livewire component tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
SDLC Phase: QUALITY GATE. Independent blind QA audit against global industry standards (OWASP, ISO 25010, CWE/SANS, WCAG, PSR, Laravel best practices). 5-phase protocol producing GitHub Issues and a compliance scorecard. No project-specific rules — purely external benchmarks.
SDLC Phase: DOCUMENTATION. Writing and maintaining project documentation — PHPDoc blocks, markdown docs, module conceptual/reference docs, metadata format, cross-references, and the documentation-first (SSOT) principle.
SDLC Phase: QUALITY GATE. Comprehensive architecture, convention, and pattern enforcement. Scans PHP/Blade code for violations of C1-C8, D1-D6, class contracts, naming conventions, security anti-patterns, and performance issues. Produces structured JSON reports for issue creation. Use after any code change, before commit, or as a periodic audit. All other code skills (code-writing, code-refactoring, livewire-development, pest-testing) delegate quality checks to this skill.
SDLC Phase: ANALYSIS. Systematic multi-layer codebase audit enforcing conventions, architecture patterns, security, and industry best practices. Produces structured findings in GitHub Issues with actionable fix recommendations.
SDLC Phase: DESIGN / REFACTORING. Systematic refactoring patterns for all code layers — extracting Actions, Entities, thinning Livewire, fixing exception handling, and enforcing architectural patterns.
SDLC Phase: IMPLEMENTATION. PHP and Laravel code writing — strict types, Action Triad, Entity/DTO/Model contracts, naming conventions, security patterns, performance rules, and non-negotiable invariants.
| name | pest-testing |
| description | SDLC Phase: TESTING. Test writing, editing, and fixing using Pest — feature tests, unit tests, architecture tests, Livewire component tests. |
Prerequisite: Load
context-awarenessfor testing conventions.
Use this skill when writing new tests, fixing failing tests, or reviewing test coverage. Covers all test types: feature, unit, Livewire component, and architecture tests.
Using this skill follows 4 phases:
context-awareness skill for project orientationvendor/bin/pint --dirty --format agentvendor/bin/phpstan analyse --no-progressphp artisan test --compact --filter={TestName}dd/dump/ray) were left behindtype(scope): description| Role | Skill |
|---|---|
| Upstream | feature-building (code to test), code-refactoring (refactored code), livewire-development (components), medialibrary-development (uploads) |
| This skill | TESTING — writes and verifies tests |
| Downstream | feature-building (integrated), sync-docs (doc updates) |
tests/{Module}/{SubModule}/{Name}Test.php
All tests live under tests/{Module}/ — the old tests/Unit/ and tests/Feature/ split has been removed.
Tests that need a database use LazilyRefreshDatabase; pure logic tests do not.
| Priority | What to Test | Type | Coverage Target |
|---|---|---|---|
| 1 | Enums | Unit | 100% |
| 2 | Entities | Unit | 100% |
| 3 | DTOs | Unit | 100% |
| 4 | Command Actions | Feature | ≥ 90% |
| 5 | Read Actions | Feature | ≥ 80% |
| 6 | Policies | Unit | 100% |
| 7 | Livewire components | Feature | ≥ 80% |
| 8 | Console Commands | Feature | ≥ 80% |
LazilyRefreshDatabase trait (not RefreshDatabase)assertModelExists() over assertDatabaseHas()| Script | What it does | Command |
|---|---|---|
scan_tests.py | Run test suite, parse per-module results | python3 scripts/scan_tests.py |
Use --module {Name} to run tests for a single module. Output:
scripts/outputs/{timestamp}-tests.json.
Test files must also pass arch-guard checks:
declare(strict_types=1) (D1)->dd() or ->dump() Pest methods insteadit_{behavior}() conventionarch-guard skill for full rule reference| Boundary | Approach |
|---|---|
| External HTTP | Http::fake() |
| File system | Storage::fake() |
| Queue | Queue::fake() |
| Notifications | Notification::fake() |
| Events | Event::fake([Specific::class]) |
| Cache | Cache::fake() |
| Auth | actingAs($user) |
If you're using shouldReceive(), reconsider — prefer fake() methods.
it('creates a resource with valid data', function () {
// Arrange
$data = CreateResourceData::from([...]);
// Act
$result = app(CreateResourceAction::class)->execute($data);
// Assert
expect($result)->toBeInstanceOf(ActionResponse::class);
expect($result->success)->toBeTrue();
assertModelExists($result->data);
});
it('rejects invalid state transitions', function () {
$record = Record::factory()->create(['status' => 'finalized']);
app(FinalizeAction::class)->execute($record);
})->throws(RejectedException::class);
LazilyRefreshDatabase used for feature testsassertModelExists() preferred over assertDatabaseHas()php artisan test --compact| Topic | Doc |
|---|---|
| Testing patterns (full) | docs/architecture/testing-pattern.md |
| Testing infrastructure | docs/infrastructure/testing.md |
| Pest documentation | search-docs with pestphp/pest |