Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Testbench Laravel Package

graham-campbell/testbench

Laravel TestBench by Graham Campbell provides testing functionality for Laravel packages, built on PHPUnit, Mockery, Orchestral Testbench, and Laravel Testbench Core. Supports PHP 7.4-8.5, PHPUnit 9-11, and Laravel 8-13.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

  • TestBench is a dev-only test scaffolding layer, not runtime infrastructure. It ships no service providers, no configuration, and no publishable assets — installation is composer require --dev graham-campbell/testbench:^6.3 and nothing else.
  • It composes four upstreams rather than replacing them: PHPUnit (runner), Mockery (mocking), orchestral/testbench (Laravel app bootstrapping for packages), and graham-campbell/testbench-core (shared abstractions). TestBench itself is thin — abstract test case classes (AbstractTestCase, AbstractAppTestCase, AbstractPackageTestCase) plus service-provider assertion helpers.
  • Consequently, the architectural decision is not "do we adopt a framework" but "do we standardise our test bootstrapping on this wrapper versus hand-rolling on Orchestral Testbench or Laravel's own Foundation\Testing\TestCase." For an application codebase, the answer is generally no. For a portfolio of first-party Laravel packages, the value is real: one consistent base case across repos, less duplicated bootstrap, and service-provider test helpers out of the box.

Integration feasibility

  • Straightforward and additive. No migration of production code, no data, no runtime surface. Fit is gated entirely by the compatibility matrix: PHP 7.4–8.5, Laravel 8–13, PHPUnit 9–11 (per the table) — with the changelog for 6.3 claiming PHPUnit 12 and Laravel 13 support.
  • The only meaningful integration work is rewriting local base test cases to extend TestBench's abstracts and moving path/provider logic into the static hooks introduced in v6.0.

Technical risk

  • Version treadmill (primary risk). Support is explicitly major-pinned across three independent axes (PHP, Laravel, PHPUnit). Every Laravel or PHPUnit major forces a TestBench major and, because v6.0 made getBasePath() and getRequiredServiceProviders() static and added return types, a breaking signature change for any team that overrode them. Budget a recurring upgrade task, not a one-off.
  • Documentation inconsistency. The README simultaneously states "supports PHPUnit 9–11," "PHPUnit 12 is not supported," and "We would highly recommend sticking with PHPUnit 12 at this time." These cannot all be true. This is a documentation defect on a decision-critical constraint and must be resolved against composer.json, not prose.
  • Adoption signal is ambiguous. The dataset reports 0 dependents, which conflicts with the package's visible Packagist download badge and its self-referential use across the maintainer's own package fleet. Treat the metric as a data artifact but do not treat it as community validation either — you are relying on one maintainer's ecosystem conventions.
  • Concentration risk. Single-maintainer project. Mitigants exist (MIT licence, small surface area you could vendor or fork, Tidelift commercial support).

Key questions

  1. Does the pinned TestBench release actually install PHPUnit 12, or must we hold at 11? What does composer.json say versus the README?
  2. Are we building packages (where this fits) or a single application (where it largely doesn't)?
  3. Is the team on PHPUnit, or committed to Pest? TestBench is PHPUnit-oriented; that is a hard fork in the road.
  4. Who owns the Laravel/PHPUnit upgrade cadence, and is that owner resourced for a recurring annual task?
  5. What do we lose by depending on orchestral/testbench directly and writing ~50 lines of base case ourselves?

Integration Approach

Stack fit

  • Suitable only where the stack is Laravel 8–13 on PHP 7.4–8.5 and the test runner is PHPUnit. Install as a require-dev; it must never appear in production dependencies and should be excluded from production autoload/CI deploy artefacts.
  • Strong fit if the organisation maintains multiple reusable Laravel packages. Weak fit for a single monolith — Laravel's built-in testing base class already covers it, and adding this layer creates an upgrade obligation for no functional gain.

Migration path

  1. Pin the TestBench major to the exact Laravel + PHPUnit line in use; treat the README matrix as authoritative until the PHPUnit 12 question is closed.
  2. Replace bespoke base test cases with inheritance from AbstractTestCase / AbstractPackageTestCase; delete duplicated framework bootstrap.
  3. Port v5-era overrides to the v6 static signatures (getBasePath(): string static; getRequiredServiceProviders(): array static, no app parameter). This is the only mechanical code change and is greppable.
  4. Verify no conflict with kylekatarnls/update-helper (explicitly conflicted) or divergent orchestral/testbench constraints from other packages in the workspace.

Compatibility

  • Lock the triplet PHP × Laravel × PHPUnit in composer.json and mirror it in the CI matrix. A green local run against a different PHPUnit minor than CI is the most likely source of phantom failures.
  • If a shared monorepo exists, validate a single resolved orchestral/testbench version across all packages before rollout — this is the usual collision point.

Sequencing

  1. Close the PHPUnit 12 documentation question.
  2. Pilot on one package with an existing, healthy suite; measure diff size and CI runtime delta.
  3. Standardise the base case and document the two static hooks as team convention.
  4. Roll out repo-by-repo; add a renewal ticket for each Laravel/PHPUnit major rather than batching upgrades.

Operational Impact

Maintenance

  • Low code surface, high cadence. Expect a dependency bump plus possible signature reconciliation roughly once per Laravel or PHPUnit major — realistically one to two engineer-days per cycle across a package portfolio. The v6.0 static-method change is the template for what future majors will look like.
  • Because TestBench tracks upstream majors closely and deliberately drops old lines (v6.0 dropped Laravel 11 and below), you cannot defer upgrades indefinitely; the package effectively enforces currency on your test stack.

Support

  • Community support via GitHub issues, an explicit security policy (disclosure to [email protected]), changelog and release notes maintained consistently. Commercial support is available through the Tidelift subscription — a credible mitigation for the single-maintainer risk if the package becomes load-bearing across many repos.

Scaling

  • No production scaling implications whatsoever; it is absent at runtime. Test-suite scaling is the real consideration: Orchestral Testbench boots a full Laravel application per test, so suite wall-clock grows with test count. Mitigate with database refresh strategies, unit tests that avoid full app boot, and CI sharding. The wrapper does not make this better or worse — it just makes the bootstrapping consistent.

Failure modes

  • Dependency deadlock: a package in the workspace pins an incompatible orchestral/testbench or PHPUnit major; resolution fails and blocks the whole upgrade.
  • Silent signature drift: overrides of the static hooks written against v5 semantics fail at runtime or, worse, silently return the wrong base path.
  • Documentation-driven misconfiguration: choosing PHPUnit 12 based on the changelog and finding it unsupported, or vice versa.
  • Abandonment: a stalled maintainer leaves the fleet pinned to aging Laravel/PHPUnit versions; forking is viable given the small surface and MIT licence, but requires an owner.
  • False confidence: passing service-provider assertion helpers do not validate real container behaviour under production configuration.

Ramp-up

  • Very shallow learning curve: two abstract classes and a handful of helpers. A PHPUnit-fluent engineer is productive within half a day.
  • Documentation is deliberately minimal ("see an example of implementation in pretty much all of my Laravel packages"), so onboarding depends on reading the maintainer's other repositories as the de facto reference corpus. Worth abstracting into an internal one-pager with your conventions and the static-hook contract.
  • The genuine ramp-up cost is organisational, not technical: establishing an owner and a recurring upgrade ritual. Given a mid-range opportunity score against direct Orchestral Testbench usage, adopt this only if the multi-package standardisation benefit is concrete — otherwise depend on the upstream directly and keep the escape hatch open.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core