Open source
Testing for Laravel
composer require --dev roundly-consulting/testing-for-laravelOverview
Dev-only test machinery for Laravel packages and applications, built so every assertion can always fail. It ships a Testbench base test case, a structural migration-order pin, a real-engine migration runner with its negative control, a two-way config contract, a secret-safe about capture, a model-swap proof, a facade-contract pin, lock recorders, a driver matrix and nine architecture presets — each one written after a real bug slipped past a test that couldn’t fail. Install it with composer require --dev: no service provider, nothing that runs in production, MIT-licensed, and no dependencies beyond official Laravel components, Pest and Testbench.
What you get
Migration-order pin
Reads foreign keys from your migration source and proves parents are created first — red on SQLite, not only on Postgres.
Real-engine runner
Applies migrations on a live Postgres or MySQL, with a negative control that proves the engine rejects a broken order.
Two-way config contract
Every key the code reads is shipped, and every shipped key is read — scraped from PHP and Blade source tokens, never a regex.
Secret-safe about capture
Demands positive proof that the about output rendered before asserting that no credential leaks.
Model-swap proof
Drives the real flow and checks the concrete class and created events of every model a swap should produce.
Lock recorders & driver matrix
Makes lockForUpdate() and its transaction depth observable on SQLite, and runs the suite across real engines.
Facade contract & arch presets
Pin the facade → manager → actions contract — documented, fakeable, every action reachable — plus nine one-line Pest arch presets.
Documentation
Installation
Install as a dev-only dependency; the Pest expectations register themselves through the package’s Pest plugin.
Package base test case
PackageTestCase: in-memory SQLite with foreign keys on, migrations by provider class, before-boot model swaps and a down()-free reset.
Migration-order pin
Parse foreign keys from migration source and prove every parent table is created first — a structural check that goes red on SQLite.
Real-engine migrations
Apply migrations on a live Postgres or MySQL and prove the engine rejects a broken order — gated so a missing engine skips visibly.
Publish-only migrations
Pin that a package publishes its migrations timestamped and never also auto-loads them — the duplicate-table bug as a test.
Config contract
Pin both ways that a config file ships exactly the keys the code reads — token-scraped, with rot-checked allow-lists and an app mode.
Secret-safe about capture
Capture an artisan about section, prove it rendered, then assert no credential leaks — a secret check that cannot pass on empty output.
Model-swap proof
Drive the real flow and prove every model it produces is the host subclass — by concrete class and created events, not instanceof.
Facade contract
Pin a package’s facade → manager → actions contract — a documented root, a real fake, every action reachable, models routed through the facade.
Architecture presets
Nine one-line Pest arch presets — strict types, final by default, model seams, dependency policy, models through the facade and more.
Preset exemptions
Exempt through the checked $ignoring parameter, not ->ignoring() — and how prefix-matched exemptions are re-checked for you.
Lock recorders
Make lockForUpdate() and its transaction depth observable on SQLite — via a model trait or a recording grammar.
Driver matrix
Run the suite on SQLite, Postgres or MySQL from TESTING_DB_* env vars, with isolated probe connections and a ready CI leg.
For applications
Use the same assertions in a plain Laravel app — no package and no base-class change — through Pest or the static Assert.
Requirements
PHP 8.4+, Laravel 12 or 13 and Pest 4; Testbench 10 or 11 comes with it. Install into require-dev only.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.