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.
Strengths:
AbstractTestCase inheritance).Weaknesses:
assertSoftDeleted, assertDatabaseHas), requiring manual assertions for common Laravel patterns.Stack Fit:
AbstractTestCase patterns.Technical Risk:
phpunit.xml.AbstractTestCase or will training be needed?assertDatabaseCount) vs. TestBench’s flexibility?Laravel\Testing) or Pest in the future?| Current State | Migration Steps | Risks |
|---|---|---|
| No Testing Framework | 1. Install TestBench (composer require graham-campbell/testbench --dev).2. Extend AbstractTestCase for package tests or AbstractAppTestCase for app tests.3. Write tests using Mockery/PHPUnit. |
None; greenfield adoption. |
| PHPUnit Only | 1. Add TestBench.2. Replace custom test bootstrapping with AbstractTestCase.3. Migrate manual mocks to Mockery.4. Update phpunit.xml to include TestBench’s paths. |
Mockery learning curve; test refactoring. |
| Pest Framework | 1. Evaluate if TestBench’s features (e.g., package testing) are missing in Pest.2. If needed, dual-boot Pest + TestBench or migrate to TestBench-only.3. Refactor tests to use AbstractTestCase. |
High refactoring cost; Pest may already cover TestBench’s use cases. |
| Legacy Laravel (<8) | 1. Downgrade TestBench to v5.x.2. Update PHPUnit to v8/9.3. Test compatibility with Laravel’s version.4. Gradually migrate to newer Laravel/TestBench versions. | Technical debt; security risks from outdated dependencies. |
| Custom Test Runner | 1. Ensure the runner supports TestBench’s AbstractTestCase.2. Update test discovery to include TestBench’s classes.3. Test parallel execution (if used). |
Integration complexity; may require custom bootstrapping. |
AbstractPackageTestCase.AbstractTestCase.getRequiredServiceProviders) to reduce boilerplate.actingAs, assertSession) where possible.AbstractTestCase.How can I help you explore Laravel packages today?