> laravel-testing

Automated testing standards with Pest and PHPUnit. Use when writing Pest or PHPUnit feature/unit tests in Laravel applications. (triggers: tests/**/*.php, phpunit.xml, feature, unit, mock, factory, sqlite)

fetch
$curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/laravel-testing?format=md"
SKILL.mdlaravel-testing

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 RefreshDatabase trait 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() and assertJson().

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.

References

┌ stats

installs/wk0
░░░░░░░░░░
github stars341
██████████
first seenMar 17, 2026
└────────────

┌ repo

HoangNguyen0403/agent-skills-standard
by HoangNguyen0403
└────────────

┌ tags

└────────────