
Laravel Tdd
This is your foundation for test-driven Laravel development. It covers the full cycle: PHPUnit and Pest setup, model factories with states and relationships, feature tests for HTTP controllers, and API endpoint testing with Sanctum auth. You get practical patterns for testing Eloquent scopes, relationships, validation, and authorization policies. The examples show real TDD workflow with the red-green-refactor cycle, complete with SQLite in-memory database config and helper methods for common scenarios like acting as authenticated users. Use this when you're building Laravel apps properly and want tests that actually catch bugs before production. The factory patterns alone will save you hours of setup boilerplate.
- skills.sh installs
- 6K
- GitHub stars
- 300.3K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add affaan-m/ecc --skill laravel-tdd --agent claude-codeInstalls into .claude/skills of the current project.
Files
Laravel Testing with TDD
Test-driven development for Laravel applications using PHPUnit, Pest, Laravel factories, and testing helpers.
When to Activate
- Writing new Laravel applications or features
- Implementing API endpoints with Sanctum or Passport authentication
- Testing Eloquent models, relationships, scopes, and accessors
- Setting up testing infrastructure for Laravel projects
- Writing feature tests for HTTP controllers and form requests
- Mocking external services (queues, mail, notifications, HTTP)
TDD Workflow for Laravel
Red-Green-Refactor Cycle
// Step 1: RED — Write a failing test
public function test_a_product_can_be_created(): void
{
$product = Product::factory()->create(['name' => 'Test Product']);
$this->assertDatabaseHas('products', ['name' => 'Test Product']);
}
// Step 2: GREEN — Write the migration, model, and factory
// Step 3: REFACTOR — Improve while keeping tests green
Setup
PHPUnit Configuration
Sponsors
Details
- Repository
- github.com/affaan-m/ecc
- Categories
- Backend & APIs, Testing & QA, Security, PHP & Laravel
- First seen
- Jul 14, 2026
More from affaan-m/ecc
All 263- Fastapi Patterns6K
- Remotion Video Creation6K
- React Patterns5.9K
- Perl Security5.9K
- Kotlin Coroutines Flows5.9K
- React Performance5.9K
- Kotlin Patterns5.9K
- Architecture Decision Records5.9K
- Deployment Patterns5.8K
- React Testing5.8K
- Pytorch Patterns5.8K
- Hexagonal Architecture5.8K
- Flutter Dart Code Review5.8K
- Frontend A11y5.8K
- Error Handling5.8K
- Ui Demo5.8K
- Agentic Engineering5.8K
- Vite Patterns5.8K
- Bun Runtime5.8K
- Agent Architecture Audit5.8K
- Nodejs Keccak2565.8K
- Security Scan5.8K
- Cpp Testing5.8K
- Django Tdd5.8K