Laravel Test Assertions

Extra PHPUnit assertions and matchers for testing Laravel applications.

Library
Composer
vv2.9.0
351stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
49/100Fair
Development Activity12
Maintenance32
Community72
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture78
Code Quality80
Innovation70
Learning Curve88

laravel-test-assertions is a developer package that adds a set of helpful assertions, matchers, and helpers on top of Laravel’s built-in testing harness. It is installed as a dev dependency and exposed through an AdditionalAssertions trait that you mix into your base test case.

The assertions target common Laravel testing needs that the framework does not cover out of the box, such as verifying that a controller action uses a given form request, applies specific middleware, or that a named route maps to the expected validation, making tests more expressive and less brittle.

What You Get

  • An AdditionalAssertions trait for your base TestCase
  • Assertions that verify controller actions use a given form request
  • Assertions that verify middleware is applied to actions or routes
  • Route-to-validation assertions by route name
  • Custom matchers for common Laravel testing scenarios
  • A small, dev-only footprint installed via Composer

Common Use Cases

  • Asserting a controller action validates input via a specific form request
  • Verifying middleware is applied to a route or action
  • Checking that a named route resolves to the expected validation rules
  • Writing more expressive feature tests for Laravel controllers

Under The Hood

Architecture - The package is compact: src/Traits/AdditionalAssertions.php contains the assertion methods that reflect over Laravel’s router and controllers to inspect form requests and middleware, src/LaravelMatchers.php provides custom matcher helpers, and src/AdditionalAssertionsServiceProvider.php wires the package into Laravel. Consumers opt in by using the trait in their base test case. Tech Stack - PHP built on PHPUnit and Laravel’s testing harness (Laravel 5.5+), distributed under the MIT license and installed as a require-dev dependency. Code Quality - It ships its own test suite and CI, and has a steady release history (20+ tags), staying compatible with new Laravel versions. The surface area is small and focused, which keeps it easy to reason about. API Design - The assertions read naturally and follow PHPUnit’s assert* naming conventions, so they compose cleanly with the framework’s existing test methods and require only a single trait import to adopt.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search