orchestra/testbench-core
Orchestra Testbench Core is the foundation for testing Laravel packages. It boots a lightweight Laravel app inside your package so you can run artisan commands, migrations, routing, and more, with compatibility across Laravel 6–12.
@WithConfig, #[UsesVendor]) and fixture management.Testbench, Testbench-BrowserKit, or Testbench-Dusk for UI/JS testing. Supports custom test skeletons and parallel test execution.BootstrapApplication, LoadEnvironmentVariables). Provides package:test CLI command to scaffold test environments.WithConfig attribute) and service provider disabling, critical for package testing.@define-env, @define-db) in v11.0.0+ may impact legacy tests. Migration path exists but requires refactoring.--parallel flag has known issues with WithFixtures (fixed in v11.0.1), requiring validation for CI/CD pipelines.Str, Validator, JsonResource) is flushed per-test, but custom stateful services may need explicit cleanup.Testbench-Dusk)?--parallel) interact with WithFixtures?testbench.yaml)?@define-env) that need migration?Str::macro()) that may leak between tests?flushState()) introduce overhead for high-volume test suites?public/ folder) required for testing (handled by Workbench)?$__filename resolution).Testbench-BrowserKit (non-JS) or Testbench-Dusk (JS-enabled).UsesVendor).WithMigrations).BootstrapApplication with Testbench base class.#[WithConfig]) for cleaner test setup.testbench.yaml for centralized config (e.g., seeders, providers).package:test CLI to scaffold initial test structure.@define-env → #[WithEnvironment]).Str::macro()) to use flushState().| Component | Compatibility | Notes |
|---|---|---|
| Laravel v12–v13 | ✅ Full support (v11.x Testbench Core) | Check composer.json constraints. |
| PHPUnit 12–13 | ✅ Native support | PestPHP support included. |
| Custom Service Providers | ✅ Via WithProviders attribute |
Supports disabling default Laravel providers. |
| Database Testing | ✅ WithMigrations, WithFactories, WithSeeders |
Transactions auto-rolled back. |
| UI Testing | ✅ Testbench-BrowserKit (non-JS) / Testbench-Dusk (JS) |
Requires additional packages. |
| Parallel Testing | ⚠️ Works but validate WithFixtures (fixed in v11.0.1+) |
CI/CD may need --parallel adjustments. |
composer.json with Testbench Core’s matrix.orchestra/testbench-core and optional extensions (e.g., orchestra/testbench-browser-kit).# Scaffold tests
vendor/bin/package:test
tests/Features/Auth, tests/Unit/Services).testbench.yaml for shared settings (e.g., seeders, providers).seeders: true
providers:
- App\Providers\AuthServiceProvider
BootstrapApplication with:
use Orchestra\Testbench\TestCase;
class MyTest extends TestCase { ... }
#[WithConfig(['app.timezone' => 'UTC'])]
--parallel flag in CI to catch edge cases.flushState() covers custom global state.testbench.yaml manages shared test settings.BindingResolutionException).Testbench-Dusk) add ~2–5x runtime.How can I help you explore Laravel packages today?