agentleFS
stoffl6781stoffl6781/claude-skill/skills/laravel-tests/SKILL.md

laravel-tests

Skill1 starsChanged 7 months agoMITView on GitHub

Generiert Pest-Tests für Laravel. Scannt Codebase, erstellt Tests nach Priorität. Nutze bei: "Tests schreiben", "Test generieren", "Pest Tests", "Feature Tests", "Unit Tests", "teste den Controller/Model/Service", "Coverage verbessern", "ist das getestet?", "Refactoring absichern".

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Plan: Test-Prioritäten festlegen (KRITISCH → NÜTZLICH)

    line 20

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Laravel Pest Test Generator

Grundprinzipien

  1. Pest-Syntax (nicht PHPUnit). 2. Arrange-Act-Assert. 3. Ein Assert pro Test.
  2. Factories nutzen. 5. RefreshDatabase. 6. Sprechende Namen.

Workflow

  1. Scan: Existierende Tests, Models, Controller, Services, Routes, Jobs identifizieren
  2. Plan: Test-Prioritäten festlegen (KRITISCH → NÜTZLICH)
  3. Infrastruktur: Pest.php, Factories, Test-Helpers prüfen
  4. Schreiben: Tests nach Patterns unten
  5. Ausführen: php artisan test oder vendor/bin/pest

Test-Prioritäten

PrioritätWas testen
KRITISCHAuth, Login, Passwort, Rollen, Payment
HOCHCRUD-Operationen, Business-Logik, API-Endpoints
MITTELValidierung, Edge Cases, Mail, Jobs
NÜTZLICHUI-Komponenten, Filament-Pages, Helfer

Test-Patterns

A) Route/Controller (Feature)

it('returns 200 for published items', function () {
    $item = Item::factory()->published()->create();
    $this->get("/items/{$item->slug}")->assertOk();
});

it('returns 404 for unpublished items', function () {
    $item = Item::factory()->unpublished()->create();
    $this->get("/items/{$item->slug}")->assertNotFound();
});

it('requires auth for admin routes', function () {
    $this->get('/admin')->assertRedirect('/login');
});

B) Service/Business Logic (Unit)

it('calculates tax correctly', function () {
    $service = new TaxService();
    expect($service->calculate(100, 'AT'))->toBe(120.0);
});

C) Model

it('has correct fillable fields', function () {
    $model = new Item();
    expect($model->getFillable())->toContain('title', 'slug');
});

it('scopes to published only', function () {
    Item::factory()->published()->count(2)->create();
    Item::factory()->unpublished()->create();
    expect(Item::published()->count())->toBe(2);
});

D) Job/Queue

it('dispatches notification job', function () {
    Queue::fake();
    $order->markAsPaid();
    Queue::assertPushed(SendInvoiceJob::class);
});

it('handles job chain correctly', function () {
    Queue::fake();
    ProcessPayment::withChain([SendInvoice::class])->dispatch($order);
    Queue::assertPushed(ProcessPayment::class);
});

E) Livewire

it('can search items', function () {
    $item = Item::factory()->create(['title' => 'Unique']);
    Livewire::test(ItemList::class)
        ->set('search', 'Unique')
        ->assertSee('Unique');
});

F) Security

it('prevents unauthorized access', function () {
    $user = User::factory()->create();
    $this->actingAs($user)->get('/admin/users')->assertForbidden();
});

it('validates CSRF on forms', function () {
    $this->post('/contact', ['name' => 'Test'])->assertStatus(419);
});

it('rate limits login attempts', function () {
    for ($i = 0; $i < 6; $i++) {
        $this->post('/login', ['email' => 'a@b.com', 'password' => 'wrong']);
    }
    $this->post('/login', ['email' => 'a@b.com', 'password' => 'wrong'])
        ->assertStatus(429);
});

G) Filament Admin

it('admin can access dashboard', function () {
    $admin = User::factory()->admin()->create();
    $this->actingAs($admin)->get('/admin')->assertOk();
});

Hinweise

  • RefreshDatabase für Feature Tests, DatabaseTransactions wenn schneller nötig
  • Mail::fake(), Queue::fake(), Notification::fake() für Side-Effects
  • Externe APIs (Mollie, VIES) immer mocken
  • Factories mit States: ->published(), ->admin(), ->withTeam()
  • Ziel: min. 80% Coverage auf Auth, Payment, Business Logic

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.