roundly-consulting / testing-for-laravel
Dev-only test machinery for Laravel packages and apps: base test cases, a structural migration-order pin, and Pest expectations that can always fail
Package info
github.com/roundly-consulting/testing-for-laravel
pkg:composer/roundly-consulting/testing-for-laravel
Fund package maintenance!
Requires
- php: ^8.4
- illuminate/contracts: ^13.0
- illuminate/database: ^13.0
- illuminate/support: ^13.0
- orchestra/testbench: ^11.0
- pestphp/pest: ^5.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.1.1
- pestphp/pest-plugin-laravel: ^5.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^2.0
Suggests
- ext-pcntl: Needed by Concurrency\Racer to fork a second database session; without it Racer::available() is false
- ext-posix: Needed by Concurrency\Racer to end the forked racer with SIGKILL; without it Racer::available() is false
Provides
None
Conflicts
None
Replaces
None
README
Testing for Laravel
The test suite that can't lie to you. A dev-only package — install it with --dev, it never
ships to production — with test machinery for Laravel packages and applications: base test cases,
a structural migration-order pin, a both-directions config contract, a secret-safe about capture
and architecture presets, each built so it can always fail.
Installation
Requires PHP 8.4, Laravel 13 and Pest 5.
composer require --dev roundly-consulting/testing-for-laravel phpunit/phpunit:^13.0 --with-all-dependencies
A fresh Laravel 13 app requires PHPUnit 12; naming phpunit/phpunit:^13.0 moves it to the PHPUnit 13
that Pest 5 needs. A project already on Pest 5 needs only the package.
Usage
Point your package's tests/TestCase.php at the base case (in-memory SQLite, foreign keys on,
migrations loaded by provider class):
use RoundlyConsulting\Testing\PackageTestCase; use RoundlyConsulting\Wallet\WalletServiceProvider; abstract class TestCase extends PackageTestCase { protected function packageProviders(): array { return [WalletServiceProvider::class]; } protected function migrationSources(): array { return [WalletServiceProvider::class]; } }
Then pin what the package ships — every assertion fails over an empty parse instead of passing:
use RoundlyConsulting\Testing\Arch\ArchPresets; it('has a runnable migration order', function (): void { expect(__DIR__.'/../../database/migrations') ->toHaveRunnableMigrationOrder(foreignKeys: 3, externalTables: ['users']); }); it('ships exactly the config keys it reads', function (): void { expect(__DIR__.'/../../config/wallet.php')->toSatisfyConfigContract(__DIR__.'/../../src'); }); ArchPresets::strictTypes('RoundlyConsulting\Wallet'); ArchPresets::finalByDefault('RoundlyConsulting\Wallet'); ArchPresets::noDebuggingLeftovers();
Documentation
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/testing-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
Support our work
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
License
MIT. See LICENSE.md.