Back to Skills

laravel-testing

verified

Write tests with Pest/PHPUnit, feature tests, unit tests, mocking, and factories. Use when testing controllers, services, models, or implementing TDD.

View on GitHub

Marketplace

fusengine-plugins

fusengine/agents

Plugin

fuse-laravel

development

Repository

fusengine/agents

plugins/laravel-expert/skills/laravel-testing/SKILL.md

Last Verified

January 22, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/fusengine/agents/blob/main/plugins/laravel-expert/skills/laravel-testing/SKILL.md -a claude-code --skill laravel-testing

Installation paths:

Claude
.claude/skills/laravel-testing/
Powered by add-skill CLI

Instructions

# Laravel Testing

## Documentation

### Testing
- [testing.md](docs/testing.md) - Testing basics
- [http-tests.md](docs/http-tests.md) - HTTP feature tests
- [database-testing.md](docs/database-testing.md) - Database testing
- [console-tests.md](docs/console-tests.md) - Console tests
- [mocking.md](docs/mocking.md) - Mocking & fakes
- [dusk.md](docs/dusk.md) - Browser testing

### Code Quality
- [pint.md](docs/pint.md) - Code style fixer

## Pest Feature Test

```php
<?php

declare(strict_types=1);

use App\Models\Post;
use App\Models\User;

describe('PostController', function () {
    beforeEach(function () {
        $this->user = User::factory()->create();
    });

    it('lists all posts', function () {
        Post::factory()->count(3)->create();

        $this->getJson('/api/v1/posts')
            ->assertOk()
            ->assertJsonCount(3, 'data');
    });

    it('creates a post when authenticated', function () {
        $data = ['title' => 'Test', 'content' => 'Content', 'status' => 'draft'];

        $this->actingAs($this->user)
            ->postJson('/api/v1/posts', $data)
            ->assertCreated()
            ->assertJsonPath('data.title', 'Test');

        $this->assertDatabaseHas('posts', ['title' => 'Test']);
    });

    it('returns 401 for unauthenticated users', function () {
        $this->postJson('/api/v1/posts', [])
            ->assertUnauthorized();
    });

    it('validates required fields', function () {
        $this->actingAs($this->user)
            ->postJson('/api/v1/posts', [])
            ->assertUnprocessable()
            ->assertJsonValidationErrors(['title', 'content']);
    });
});
```

## Unit Test with Mocking

```php
<?php

declare(strict_types=1);

use App\Services\PostService;
use App\Repositories\Contracts\PostRepositoryInterface;

describe('PostService', function () {
    it('creates a post with valid data', function () {
        $repository = Mockery::mock(PostRepositoryInterface::class);
        $repository->sho

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
3136 chars