hoangnguyen0403-laravel-testing
1
总安装量
1
周安装量
#41146
全站排名
安装命令
npx skills add https://smithery.ai
Agent 安装分布
claude-code
1
Skill 文档
Laravel Testing
Priority: P1 (HIGH)
Structure
tests/
âââ Feature/ # Integration/HTTP tests
âââ Unit/ # Isolated logic tests
âââ TestCase.php
Implementation Guidelines
- Framework: Use Pest for modern DX or PHPUnit for legacy parity.
- Fresh Context: Use
RefreshDatabasetrait for data isolation. - Factories: Create test data via Eloquent Factories.
- Mockery: Use
$this->mock()for external service substitution. - In-Memory: Use SQLite
:memory:for high-speed unit tests. - HTTP Assertions: Use
$response->assertStatus()andassertJson().
Anti-Patterns
- Real APIs: No real network calls: Always mock or stub.
- Global State: No state leakage: Refresh DB between tests.
- Manual Insert: No DB::table()->insert(): Use Factories.
- Slow Logic: No heavy unit tests: Move to Feature tests.