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 Core

Testbench Core Laravel Package

graham-campbell/testbench-core

Laravel TestBench Core by Graham Campbell provides reusable testing functionality for Laravel packages and applications, supporting PHPUnit 9-12 and Laravel 8-13 on PHP 7.4-8.5.

View on GitHub
Deep Wiki
Context7

TestBench Core Provides Some Testing Functionality For Laravel

Frequently asked questions about Testbench Core
What is graham-campbell/testbench-core used for?
It is a lightweight, dev-only testing utility for Laravel package and application test suites. It provides a TestbenchTestCase base class plus traits such as FacadeTrait, ServiceProviderTrait and MockeryTrait, along with helper assertions like assertArraySubset. These let a PHPUnit suite boot Laravel's container, resolve facades and exercise service providers without each package reimplementing that plumbing.
How do I install TestBench Core in a Laravel package?
Run composer require "graham-campbell/testbench-core:^4.3" --dev. It belongs in require-dev because it is purely a test harness and ships no runtime code. There is no service provider to register and no configuration to publish, so installation is complete once Composer resolves it.
Which PHP, PHPUnit and Laravel versions does TestBench Core support?
Version 4.3 supports PHP 7.4 through 8.5, PHPUnit 9 through 12, and Laravel 8 through 13. Composer resolves the matching release from your existing constraints, so pinning the package version effectively pins all three upgrade trains together. Check the compatibility table in the README before bumping Laravel or PHPUnit.
Why is PHPUnit 13 not supported by TestBench Core?
The maintainer cites volatility across PHPUnit minor releases and explicitly recommends staying on PHPUnit 12 for now. That means support for PHPUnit 13 will arrive only when the upstream API settles enough to guarantee a stable harness. Plan your PHPUnit pin around this rather than assuming a release-day upgrade.
Does TestBench Core affect production code or runtime behavior?
No. The package has zero production surface area: no service providers, no configuration, and no runtime bootstrapping logic. Its blast radius is confined to composer.json require-dev and the test job in CI. It cannot affect request latency, deployment artifacts, or application container behavior.
How do I write a test case with TestbenchTestCase and the provided traits?
Extend the TestbenchTestCase base class, or compose the individual traits into your own base test case. You then implement the required accessor methods, such as getFacadeAccessor, getFacadeRoot, getFacadeClass and getServiceProviderClass, which are static and typed since v4. The upstream README is deliberately thin, so the practical path is reading Graham Campbell's other Laravel packages for working examples and writing an internal usage note for your team.
What changed in TestBench Core v4.0 and could it break my test suite?
Version 4.0 made FacadeTrait::getFacadeAccessor, getFacadeClass, getFacadeRoot and getServiceProviderClass static, made ServiceProviderTrait::getServiceProviderClass static, and added property and return type declarations throughout. That is a legitimate major bump, but it breaks every adopting test suite at once, which in a monorepo means a single coordinated pull request rather than a routine composer update. Budget for it as a project-level change when the next major lands.
Is TestBench Core useful in a standard Laravel application or only for packages?
Its value concentrates where service providers and facades are the public contract, such as publishable packages, SDK-style shared libraries, modular domain packages and multi-tenant plugins. In a conventional monolith with feature and HTTP tests it solves a problem you likely do not have. That is a portfolio-shape question worth answering before evaluating the library itself.
How risky is depending on TestBench Core given it is a single-maintainer package?
It is effectively maintained by one person, which is the main bus-factor concern for a build-blocking dev dependency. Mitigants include the MIT license, a published security policy, CI-backed releases, and a Tidelift commercial channel as a credible escalation path if you need contractual coverage. The bigger day-to-day risk is coupling: PHP, PHPUnit and Laravel upgrade windows move as a single unit gated by this package's release cadence.
What are the alternatives to TestBench Core, such as orchestra/testbench?
orchestra/testbench is the widely used alternative, offering a fuller package-testing skeleton with more built-in scaffolding. TestBench Core is intentionally lighter and acts as the shared foundation beneath Graham Campbell's TestBench family, while some teams simply inline the small traits into their own base test case. Note that a reported dependent count of zero for this package is a measurement artifact, since dev-only dependencies are routinely excluded from dependent graphs.
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.
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route