Claude Code Plugins

Community-maintained marketplace

Feedback
4
0

Comprehensive testing patterns with Pest. Use when working with tests, testing patterns, or when user mentions testing, tests, Pest, PHPUnit, mocking, factories, test patterns.

Install Skill

1Download skill
2Enable skills in Claude

Open claude.ai/settings/capabilities and find the "Skills" section

3Upload to Claude

Click "Upload skill" and select the downloaded ZIP file

Note: Please verify skill by going through its instructions before using it.

SKILL.md

name laravel-testing
description Comprehensive testing patterns with Pest. Use when working with tests, testing patterns, or when user mentions testing, tests, Pest, PHPUnit, mocking, factories, test patterns.

Laravel Testing

Testing patterns with Pest: Arrange-Act-Assert, proper mocking, null drivers.

Core Concepts

testing.md - Core testing guide:

  • Triple-A pattern (Arrange, Act, Assert)
  • Testing actions in isolation
  • Only mock what you own
  • Using factories for test data
  • Null driver pattern
  • Avoiding brittle tests
  • Feature vs unit tests

testing-conventions.md - Testing conventions:

  • Test structure and organization
  • Naming conventions
  • Dataset usage
  • Common patterns

Pattern

it('creates order successfully', function () {
    // Arrange
    $user = User::factory()->create();
    $dto = CreateOrderDto::from([
        'user_id' => $user->id,
        'items' => [
            ['product_id' => 1, 'quantity' => 2],
        ],
    ]);

    // Act
    $order = app(CreateOrderAction::class)($dto);

    // Assert
    expect($order)
        ->user_id->toBe($user->id)
        ->items->toHaveCount(1);

    $this->assertDatabaseHas('orders', [
        'user_id' => $user->id,
    ]);
});

Key principles:

  • Test actions in isolation (unit tests)
  • Test controllers for HTTP integration (feature tests)
  • Use null drivers to avoid external API calls
  • Use factories for all test data
  • Only mock external dependencies, not your own code