Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

laravel-testing

БесплатноБез исполняемых скриптовНе проверен

Use when testing controllers, services, or models, or implementing TDD on Laravel 13 with Pest 5 / PHPUnit 13 (or Pest 4 / PHPUnit 12 on PHP 8.3).

Fusengineот Fusengine★ 36 звёзд на GitHub

Об этом скилле

Covers Laravel 13 testing with Pest 5 / PHPUnit 13 (Pest 4 / PHPUnit 12 on PHP 8.3): feature tests (HTTP, full stack), unit tests (isolated classes), and architecture tests; Pest syntax (it/test/describe), datasets; HTTP testing (requests, JSON assertions, auth/actingAs, status/redirect assertions); database testing (RefreshDatabase, factories, DB assertions); mocking (services, spies, Mail/Queue/Event fakes, Http::fake, time travel); console/Artisan command tests; and PHPUnit-attribute-based seeding (#[Seed], #[Seeder]).

Laravel Testing

Agent Workflow (MANDATORY)

Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:

  1. fuse-ai-pilot:explore-codebase - Analyze existing test patterns
  2. fuse-ai-pilot:research-expert - Verify Pest/PHPUnit docs via Context7
  3. mcp__context7__query-docs - Check assertion and mocking patterns

After implementation, run fuse-ai-pilot:sniper for validation.


Overview

Type Purpose Location
Feature HTTP, full stack tests/Feature/
Unit Isolated classes tests/Unit/
Arch Code architecture tests/Arch.php

Decision Guide: Test Type

What to test?
├── HTTP endpoint → Feature test
├── Service/Policy logic → Unit test
├── Code structure → Arch test
├── External API → Mock with Http::fake()
├── Mail/Queue/Event → Use Fakes
└── Database state → assertDatabaseHas()

Decision Guide: Test Strategy

Coverage strategy?
├── Feature tests (70%) → Critical flows
├── Unit tests (25%) → Business logic
├── E2E tests (5%) → User journeys
└── Arch tests → Structural rules

Critical Rules

  1. Use RefreshDatabase for database isolation
  2. Use factories for test data (never raw inserts)
  3. Mock external services - Never call real APIs
  4. Test edge cases - Empty, null, boundaries
  5. Run parallel - pest --parallel for speed

Reference Guide

Pest Basics

Topic Reference When to Consult
Pest Syntax pest-basics.md it(), test(), describe()
Datasets pest-datasets.md Data providers, hooks
Architecture pest-arch.md arch() tests

HTTP Testing

Topic Reference When to Consult
Requests http-requests.md GET, POST, headers
JSON API http-json.md API assertions
Authentication http-auth.md actingAs, guards
Assertions http-assertions.md Status, redirects

Database Testing

Topic Reference When to Consult
Basics database-basics.md RefreshDatabase
Factories database-factories.md Factory patterns
Assertions database-assertions.md DB assertions

Mocking

Topic Reference When to Consult
Services mocking-services.md Mock, spy
Fakes mocking-fakes.md Mail, Queue, Event
HTTP & Time mocking-http.md Http::fake, travel

Other

Topic Reference When to Consult
Console console-tests.md Artisan tests
Troubleshooting troubleshooting.md Common errors

Templates

Template When to Use
FeatureTest.php.md HTTP feature test
UnitTest.php.md Service unit test
ArchTest.php.md Architecture test
ApiTest.php.md REST API test
PestConfig.php.md Pest configuration

Quick Reference

// Feature test
it('creates a post', function () {
    $user = User::factory()->create();

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

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

// With dataset
it('validates emails', function (string $email, bool $valid) {
    // test logic
})->with([
    ['[email protected]', true],
    ['invalid', false],
]);

// Mock facade
Mail::fake();
// ... action ...
Mail::assertSent(OrderShipped::class);

Commands

# Run all tests
php artisan test

# Pest directly
./vendor/bin/pest

# Paral
Полный SKILL.md на GitHub

Установить laravel-testing в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/console-tests.mdreferences/database-assertions.mdreferences/database-basics.mdreferences/database-factories.mdreferences/http-assertions.mdreferences/http-auth.mdreferences/http-json.mdreferences/http-requests.mdreferences/mocking-fakes.mdreferences/mocking-http.mdreferences/mocking-services.mdreferences/pest-arch.mdreferences/pest-basics.mdreferences/pest-datasets.mdreferences/templates/ApiTest.php.mdreferences/templates/ArchTest.php.mdreferences/templates/FeatureTest.php.mdreferences/templates/PestConfig.php.mdreferences/templates/UnitTest.php.mdreferences/troubleshooting.md

FAQ

Что делает скилл laravel-testing?

Use when testing controllers, services, or models, or implementing TDD on Laravel 13 with Pest 5 / PHPUnit 13 (or Pest 4 / PHPUnit 12 on PHP 8.3).

Как установить скилл laravel-testing?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл laravel-testing запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить laravel-testing с