---
title: "Testing for Laravel — docs | Roundly"
description: "Docs for Testing for Laravel: Pest assertions that can always fail — migration order, real-engine runs, config contracts, model swaps and arch presets."
url: https://roundly-consulting.com/open-source/docs/testing-for-laravel
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

Open source

# Testing for Laravel

Install

`composer require --dev roundly-consulting/testing-for-laravel`

Requires: PHP ^8.4 · Laravel ^12.0|^13.0

[GitHub](https://github.com/roundly-consulting/testing-for-laravel) [Packagist](https://packagist.org/packages/roundly-consulting/testing-for-laravel) [Donate (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Patreon](https://www.patreon.com/cw/roundly)

## Overview

Dev-only test machinery for Laravel packages and applications, built so every assertion can always fail. It ships a Testbench base test case that can keep its migrated schema between tests, 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 that also keeps secrets out of stack traces, lock recorders, a driver matrix and eleven 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.

#### Migrate once per worker

Opt in and each worker migrates once, then empties the tables and rewinds the ids between tests — no wrapping transaction, and a changed schema is caught.

#### 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, secrets kept out of traces — plus eleven Pest arch presets.

### Documentation

#### [Installation](https://roundly-consulting.com/open-source/docs/testing-for-laravel/installation.md)

Install as a dev-only dependency; the Pest expectations register themselves through the package’s Pest plugin.

#### [Package base test case](https://roundly-consulting.com/open-source/docs/testing-for-laravel/package-test-case.md)

PackageTestCase: SQLite with foreign keys on, migrations by provider class, before-boot model swaps, a down()-free reset and an opt-in kept schema.

#### [Migration-order pin](https://roundly-consulting.com/open-source/docs/testing-for-laravel/migration-order.md)

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](https://roundly-consulting.com/open-source/docs/testing-for-laravel/real-engine-migrations.md)

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](https://roundly-consulting.com/open-source/docs/testing-for-laravel/publish-only-migrations.md)

Pin that a package publishes its migrations timestamped and never also auto-loads them — the duplicate-table bug as a test.

#### [Config contract](https://roundly-consulting.com/open-source/docs/testing-for-laravel/config-contract.md)

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](https://roundly-consulting.com/open-source/docs/testing-for-laravel/about-secrets.md)

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](https://roundly-consulting.com/open-source/docs/testing-for-laravel/model-swap.md)

Drive the real flow and prove every model it produces is the host subclass — by concrete class and created events, not instanceof.

#### [Facade contract](https://roundly-consulting.com/open-source/docs/testing-for-laravel/facade-contract.md)

Pin a package’s facade → manager → actions contract — a documented root, a real fake, every action reachable, secrets redacted, models via the facade.

#### [Architecture presets](https://roundly-consulting.com/open-source/docs/testing-for-laravel/architecture-presets.md)

Eleven one-line Pest arch presets — strict types, final by default, model and factory seams, dependency policy, vendor bans, facade-only models and more.

#### [Preset exemptions](https://roundly-consulting.com/open-source/docs/testing-for-laravel/arch-exemptions.md)

Exempt through the checked $ignoring parameter, not ->ignoring() — and how prefix-matched exemptions are re-checked for you.

#### [Lock recorders](https://roundly-consulting.com/open-source/docs/testing-for-laravel/lock-recorders.md)

Make lockForUpdate() and its transaction depth observable on SQLite — via a model trait or a recording grammar.

#### [Driver matrix](https://roundly-consulting.com/open-source/docs/testing-for-laravel/driver-matrix.md)

Run the suite on SQLite, Postgres or MySQL from TESTING\_DB\_\* env vars, with isolated probe connections and a ready CI leg.

#### [For applications](https://roundly-consulting.com/open-source/docs/testing-for-laravel/applications.md)

Use the same assertions in a plain Laravel app — no package and no base-class change — through Pest or the static Assert.

#### [Requirements](https://roundly-consulting.com/open-source/docs/testing-for-laravel/requirements.md)

PHP 8.4+, Laravel 12 or 13, and Pest 4 or Pest 5 (Pest 5 on Laravel 13); 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 crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## 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.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source.md)
