laravel-tdd

Solid

Test-driven development for Laravel with PHPUnit and Pest, factories, database testing, fakes, and coverage targets.

AI & Automation 196,640 stars 30253 forks Updated 2 days ago MIT

Install

View on GitHub

Quality Score: 96/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Laravel TDD Workflow Test-driven development for Laravel applications using PHPUnit and Pest with 80%+ coverage (unit + feature). ## When to Use - New features or endpoints in Laravel - Bug fixes or refactors - Testing Eloquent models, policies, jobs, and notifications - Prefer Pest for new tests unless the project already standardizes on PHPUnit ## How It Works ### Red-Green-Refactor Cycle 1) Write a failing test 2) Implement the minimal change to pass 3) Refactor while keeping tests green ### Test Layers - **Unit**: pure PHP classes, value objects, services - **Feature**: HTTP endpoints, auth, validation, policies - **Integration**: database + queue + external boundaries Choose layers based on scope: - Use **Unit** tests for pure business logic and services. - Use **Feature** tests for HTTP, auth, validation, and response shape. - Use **Integration** tests when validating DB/queues/external services together. ### Database Strategy - `RefreshDatabase` for most feature/integration tests (runs migrations once per test run, then wraps each test in a transaction when supported; in-memory databases may re-migrate per test) - `DatabaseTransactions` when the schema is already migrated and you only need per-test rollback - `DatabaseMigrations` when you need a full migrate/fresh for every test and can afford the cost Use `RefreshDatabase` as the default for tests that touch the database: for databases with transaction support, it runs migrations once per test run (via ...

Details

Author
affaan-m
Repository
affaan-m/everything-claude-code
Created
4 months ago
Last Updated
2 days ago
Language
JavaScript
License
MIT

Integrates with

Related Skills