Laravel Testing

Enforce automated testing standards for Laravel applications using Pest and PHPUnit.

51|6|Updated Mar 28, 2019
One-click install
npx skills add https://github.com/Mte90/dotfiles --skill laravel-testing-mte90
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Laravel Testing
Source: https://github.com/Mte90/dotfiles/tree/main/.config/opencode/skills/laravel/testing
Command: npx skills add https://github.com/Mte90/dotfiles --skill laravel-testing-mte90

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a standardized approach to writing efficient and reliable automated tests for Laravel applications, ensuring code quality and reducing bugs.

Core Features & Use Cases

  • Test Frameworks: Supports both modern Pest and traditional PHPUnit.
  • Data Management: Utilizes database refreshing and Eloquent factories for isolated test data.
  • Mocking: Facilitates mocking of external services for focused unit testing.
  • Use Case: Quickly write feature tests for a new API endpoint, ensuring it returns the correct status code and JSON response, while using an in-memory SQLite database for speed.

Quick Start

Write a new feature test for the user registration endpoint using Pest.

Frequently Asked Questions about Laravel Testing

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

FAQPage Schema
How do I write Laravel feature tests using Pest and PHPUnit?

Laravel automated testing standards enforce efficient test creation for Pest and PHPUnit. You can write feature tests by validating API endpoint status codes and JSON responses using defined expectations and isolated data.

How does RefreshDatabase work with Eloquent Factories in Laravel testing?

RefreshDatabase manages database state by resetting it between tests, while Eloquent Factories generate fake model data. Together they ensure isolated integration testing with predictable data generation for Laravel applications.

Can I use an in-memory SQLite database for Laravel unit tests?

In-memory SQLite is utilized for performance optimization in Laravel unit tests. It enables rapid database operations without persistent storage overhead, significantly speeding up test suite execution for integration and unit testing.

What is the best way to mock external dependencies in Laravel tests?

Mocking external dependencies in Laravel tests is handled by replacing external services with simulated responses. This facilitates focused unit testing by isolating application logic from third-party API interactions.

Does this testing approach support both Pest and PHPUnit frameworks?

Yes, both modern Pest and traditional PHPUnit frameworks are supported. This allows developers to write automated tests using their preferred syntax while maintaining standardized testing methodologies for Laravel applications.

Why use automated testing standards for Laravel applications?

Automated testing standards for Laravel applications ensure code quality and reduce bugs by providing a standardized approach. This enforces reliable coverage for integration and unit tests, catching regressions early.