Write tests with Pest/PHPUnit, feature tests, unit tests, mocking, and factories. Use when testing controllers, services, models, or implementing TDD.
/plugin marketplace add fusengine/agents/plugin install fuse-laravel@fusengine-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
docs/console-tests.mddocs/database-testing.mddocs/dusk.mddocs/http-tests.mddocs/mocking.mddocs/pint.mddocs/testing.md<?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']);
});
});
<?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->shouldReceive('create')
->once()
->andReturn(new Post(['title' => 'Test']));
$service = new PostService($repository);
$post = $service->create(['title' => 'Test']);
expect($post->title)->toBe('Test');
});
});
<?php
declare(strict_types=1);
namespace Database\Factories;
final class PostFactory extends Factory
{
public function definition(): array
{
return [
'title' => fake()->sentence(),
'content' => fake()->paragraphs(3, true),
'status' => PostStatus::Draft,
'user_id' => User::factory(),
];
}
public function published(): static
{
return $this->state([
'status' => PostStatus::Published,
'published_at' => now(),
]);
}
}
// Response
$response->assertOk(); // 200
$response->assertCreated(); // 201
$response->assertUnauthorized(); // 401
$response->assertUnprocessable(); // 422
// JSON
$response->assertJson(['key' => 'value']);
$response->assertJsonPath('data.id', 1);
$response->assertJsonCount(3, 'data');
// Database
$this->assertDatabaseHas('posts', ['title' => 'Test']);
$this->assertDatabaseMissing('posts', ['title' => 'Deleted']);
$this->assertSoftDeleted('posts', ['id' => 1]);
// Mock HTTP
Http::fake([
'api.example.com/*' => Http::response(['data' => 'test'], 200),
]);
// Mock service
$this->mock(PaymentService::class, function ($mock) {
$mock->shouldReceive('charge')->once()->andReturn(true);
});
This skill should be used when the user asks about libraries, frameworks, API references, or needs code examples. Activates for setup questions, code generation involving libraries, or mentions of specific frameworks like React, Vue, Next.js, Prisma, Supabase, etc.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.