affaan-m avatar

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-code

Installs 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
1affaan-m avatarfastapi-patternsaffaan-m/eccFastAPI best practices covering project structure, Pydantic v2 schemas, dependency injection, async handlers, authentication, authorization, transactional servi6Kskills.sh installs
2aws avataraws-blocksaws/agent-toolkit-for-awsGuides building full-stack applications with AWS Blocks — an Infrastructure-from-Code framework. Applies when creating APIs, selecting Building Blocks (KVStore,5.9Kskills.sh installs
3okx avatarokx-dex-wsokx/onchainos-skillsUse this skill when the user mentions 'onchainos ws', 'ws start', 'ws poll', 'ws stop', 'ws channels', 'ws session', 'ws channel-info', 'idle-timeout', 'idle ti5.8Kskills.sh installs
4qianwen-ai avatarqianwen-usageqianwen-ai/qianwen-ai[QianWen] Manage account auth and query usage/billing. Use for: login, logout, check usage, view billing, free tier quota, Token Plan status, pay-as-you-go cost5.8Kskills.sh installs
5affaan-m avatardjango-tddaffaan-m/eccDjango testing strategies with pytest-django, TDD methodology, factory_boy, mocking, coverage, and testing Django REST Framework APIs.5.8Kskills.sh installs
6pexoai avatarvideoagent-image-studiopexoai/pexo-skillsTired of juggling 8 API keys? This skill gives you one-command access to Midjourney, Flux, Ideogram, and more, with zero setup. Use when you want to generate an5.6Kskills.sh installs