skillfed

laravel-testing

This skill guides you through testing Laravel 13 applications with either Pest PHP 4 or PHPUnit 12, covering 24 rules across HTTP endpoints, model factories, database state verification, service mocking, and authentication patterns. It detects your project's testing framework automatically and provides syntax examples for both frameworks side-by-side, so you can write fast, readable tests regardless of which one you use.

laravel-testing helps you write feature and unit tests for Laravel 13 using Pest PHP 4 or PHPUnit 12.

AI-generated summary based on this skill's SKILL.md

58 9 MIT updated by AsyrafHussin

Install

AsyrafHussin/agent-skills/laravel-testing

git clone https://github.com/AsyrafHussin/agent-skills
cp -r agent-skills/skills/laravel-testing ~/.claude/skills/laravel-testing
npx skillfed install AsyrafHussin/agent-skills/laravel-testing

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

What is laravel-testing and which frameworks does it support?

laravel-testing is a skill for writing feature and unit tests in Laravel 13 applications. It supports both Pest PHP 4 and PHPUnit 12, automatically detecting your project's testing framework and providing syntax examples for both side-by-side. The skill covers 24 rules spanning HTTP endpoints, model factories, database assertions, service mocking, and authentication patterns to help you write fast, readable tests.

How do I choose between Pest PHP 4 and PHPUnit 12 for testing?

laravel-testing helps you evaluate both frameworks so you can make an informed choice. Pest PHP 4 offers expressive, readable syntax with describe/it blocks, while PHPUnit 12 provides traditional assertion methods. The skill provides side-by-side examples for both, letting you see how the same test looks in each framework and decide which aligns better with your team's preferences and project needs.

How to write tests in laravel with model factories and relationships?

laravel-testing covers creating model factories and test data with relationships. You define factories for your models, then use them in tests to generate realistic data with associated relationships. The skill shows you how to chain factory calls, set specific attributes, and create related records—enabling you to build complex test scenarios quickly without manual database setup.

How do I assert database state and HTTP responses in Laravel tests?

laravel-testing teaches you to verify both database state and HTTP responses. For database assertions, you use methods to check that records exist, were created, or were soft-deleted. For HTTP responses, you assert status codes, JSON structure, and response content. The skill covers both Pest and PHPUnit syntax, so you can confidently verify your application's behavior at the database and API levels.

Can laravel-testing help me mock Mail, Queue, and Events?

Yes. laravel-testing covers mocking and faking Laravel services including Mail, Queue, and Events. You learn how to prevent actual emails from sending during tests, assert that jobs were queued, and verify events were dispatched. The skill provides examples for both Pest PHP 4 and PHPUnit 12, letting you fake these services and focus on testing your application logic in isolation.

What testing patterns and organization does laravel-testing recommend?

laravel-testing guides you through test organization patterns, including how to structure feature and unit tests, use database transactions for isolation, and organize test datasets. It covers authentication testing for APIs (including Sanctum tokens), soft delete scenarios, and parameterized tests. The skill helps you build a maintainable test suite that scales with your Laravel 13 application.

SKILL.md

rendered from the published skill — quoted content, verbatim

Laravel 13 Testing — Pest PHP 4 & PHPUnit 12

> Supports both Pest PHP 4 and PHPUnit 12. See Framework Detection below. > > PHPUnit version note: Laravel 13 ships with phpunit/phpunit: ^12.5.12 in its default composer.json. All patterns in this skill are compatible with PHPUnit 11, 12, and 13.

Comprehensive testing guide for Laravel 13 applications. Contains 24 rules across 6 categories for writing fast, readable, and reliable tests. Supports both Pest PHP 4 and PHPUnit 12 (Laravel 13 default).

Framework Detection

Before writing or reviewing any test code, detect which testing framework the project uses:

Step 1 — Check composer.json

```bash

Look for these in

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 15 files
skills/laravel-testing/AGENTS.md
skills/laravel-testing/README.md
skills/laravel-testing/SKILL.md
skills/laravel-testing/metadata.json
skills/laravel-testing/rules/auth-acting-as.md
skills/laravel-testing/rules/auth-sanctum.md
skills/laravel-testing/rules/db-assert-has.md
skills/laravel-testing/rules/db-assert-missing.md
skills/laravel-testing/rules/db-assert-soft-deletes.md
skills/laravel-testing/rules/factory-define.md
skills/laravel-testing/rules/factory-relationships.md
skills/laravel-testing/rules/factory-sequences.md
skills/laravel-testing/rules/factory-states.md
skills/laravel-testing/rules/fake-ai-agent.md
skills/laravel-testing/rules/fake-ai-data.md

Related skills

Tags

test-framework-selection http-endpoint-testing factory-data-generation assertion-patterns service-mocking test-structure-organization api-authentication-testing database-state-verification