graham-campbell/testbench
Testing utilities for Laravel packages, built on PHPUnit, Mockery, Orchestral Testbench, and Laravel Testbench Core. Supports Laravel 8–13 and PHP 7.4–8.5, with compatibility for PHPUnit 9–11 to help you run fast, reliable package test suites.
AbstractAppTestCase, AbstractPackageTestCase) allow customization without reinventing boilerplate.Mockery::mock()), reducing flakiness in isolated tests.getBasePath() and getRequiredServiceProviders() may require updates to existing test suites.createApplication()). Best for package-level or modular testing.assertInJson) needed beyond what Orchestral Testbench provides?createApplication() instead).spatie/laravel-test-factories).// Before (Laravel native)
class MyTest extends \Tests\TestCase {}
// After (TestBench)
class MyTest extends \GrahamCampbell\TestBench\AbstractAppTestCase {}
composer.json:
"require-dev": {
"graham-campbell/testbench": "^6.3",
"orchestral/testbench": "^3.6",
"mockery/mockery": "^1.6"
}
AbstractAppTestCase for app-level tests.AbstractPackageTestCase for package-specific tests (e.g., service providers).createApplication():
getApplication() or getPackageProviders() methods.partialMock() with Mockery’s mock() where applicable.register() method.@package vs. @app tags).| Risk | Impact | Mitigation |
|---|---|---|
| PHPUnit 12 instability | Test failures or flakiness | Pin to PHPUnit 11 or 9/10. |
| Mockery deprecations | Broken mocks in future Laravel | Monitor Mockery updates; refactor if needed. |
| Orchestral Testbench BC | Underlying changes break tests | Test against minor updates early. |
| Laravel version drift | Tests fail on newer Laravel | Regularly test against latest supported Laravel. |
AbstractPackageTestCase for package devs and AbstractAppTestCase for modular testing.composer.json.createApplication() calls.How can I help you explore Laravel packages today?