testing-patterns

Document PHPUnit-based Laravel testing workflows including factories and auth guards.

132|42|Updated Aug 19, 2020
One-click install
npx skills add https://github.com/OpenLitterMap/openlittermap-web --skill testing-patterns-openlittermap
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-patterns
Source: https://github.com/OpenLitterMap/openlittermap-web/tree/main/.ai/skills/testing-patterns
Command: npx skills add https://github.com/OpenLitterMap/openlittermap-web --skill testing-patterns-openlittermap

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a consolidated guide to implement and maintain robust testing patterns for Laravel projects, reducing flaky tests and improving test reliability.

Core Features & Use Cases

  • Unified patterns for PHPUnit tests, including RefreshDatabase, Event::fake, and guard testing.
  • Factory-driven data setup with related models for complex test scenarios.
  • Guidance on seeding, deprecated tests handling, and test organization for scalable codebases.

Quick Start

Start by refactoring an existing feature test to use factories, then apply Event::fake patterns and correct auth guard usage to achieve stable, isolated tests.

Frequently Asked Questions about testing-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the best way to structure Laravel tests to prevent flaky results?

Standardize Laravel tests using base test case patterns, factory-driven data creation, and RefreshDatabase to ensure safe test isolation and reduce flaky results.

How do I use factories to set up complex data in PHPUnit tests?

Use test factories to generate related models for complex test scenarios, enabling structured and reliable data creation within your PHPUnit testing workflows.

When should I use Event::fake in Laravel feature tests?

Apply Event::fake patterns during Laravel feature testing to isolate event logic, preventing actual event listeners from executing and ensuring accurate assertions.

Does this testing approach support admin and auth guard scenarios?

Yes, these PHPUnit testing patterns include specific guidance for admin and auth guard testing, ensuring correct guard usage and secure test isolation.

How do I handle seeding and deprecated tests in a scalable Laravel codebase?

Apply standardized testing workflows for seeding data and managing deprecated tests, ensuring scalable codebase organization and reliable PHPUnit test execution.