Weave Code
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

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.

View on GitHub
Deep Wiki
Context7

graham-campbell/testbench is a Laravel-focused testing helper that builds on PHPUnit, Mockery, Orchestral Testbench, and Laravel Testbench Core to make package and application tests easier to write and run. It provides a consistent Testbench foundation across multiple Laravel and PHPUnit versions, helping you bootstrap a minimal Laravel app for fast, reliable test suites.

  • Seamless Laravel bootstrapping for package testing
  • Integrates PHPUnit and Mockery workflows
  • Built on Orchestral Testbench + Testbench Core
  • Broad compatibility (Laravel 8–13, PHPUnit 9–11, PHP 7.4–8.5)
  • Actively maintained with changelog, releases, and security policy
Frequently asked questions about Testbench
How do I install Laravel TestBench for Laravel 12 or 13?
Run `composer require --dev graham-campbell/testbench` in your project. No additional configuration is needed—just extend `AbstractPackageTestCase` or `AbstractAppTestCase` in your test classes. Ensure your `phpunit.xml` config matches PHPUnit 9–11 (TestBench drops PHPUnit 12 support due to instability).
Can I use TestBench for testing a standalone Laravel package without a full app?
Yes, TestBench is designed for this exact use case. Extend `AbstractPackageTestCase` in your package tests, and it will handle bootstrapping Laravel’s core services in isolation. This avoids requiring a full Laravel installation for package-level testing.
What’s the difference between `AbstractPackageTestCase` and `AbstractAppTestCase`?
`AbstractPackageTestCase` is optimized for testing Laravel packages in isolation (e.g., service providers, models, or standalone components). `AbstractAppTestCase` is for application-level tests where you need a full Laravel environment. Choose based on whether you’re testing a package or an app.
Does TestBench support Laravel’s built-in testing tools like `php artisan test`?
No, TestBench relies on Orchestral Testbench (a fork of Laravel’s legacy test tools) and doesn’t integrate with Laravel’s native `php artisan test` or PEST. If you’re using PEST or Laravel’s built-in tools, TestBench may add unnecessary complexity.
Why does TestBench exclude PHPUnit 12 support? Is it stable?
TestBench explicitly drops PHPUnit 12 due to reported instability across minor releases. The maintainer recommends sticking with PHPUnit 11 for consistency. If PHPUnit 12 stabilizes, monitor updates or consider migrating to Laravel’s native testing tools.
How do I mock services in TestBench? Does it use Mockery or PHPUnit’s native mocks?
TestBench uses Mockery for mocking, which is deprecated in PHPUnit 11+. If you’re invested in Mockery’s syntax, TestBench is a good fit. For new projects, consider PHPUnit’s native mocks or plan a migration path away from Mockery.
Will TestBench work with CI/CD pipelines like GitHub Actions or parallel test execution?
Yes, TestBench integrates seamlessly with CI/CD. It supports parallel test execution out of the box. However, avoid using `kylekatarnls/update-helper` in your CI, as TestBench explicitly blocks it to prevent conflicts with its test environment setup.
What if I’m using Laravel 8 or 9? Are there breaking changes from older versions?
TestBench supports Laravel 8–13, but versions 6.0+ introduced static methods like `getBasePath()` and `getRequiredServiceProviders()`. If you’re upgrading from an older version, audit your test suite for dynamic calls to these methods and update them to static calls.
Is TestBench a good choice if I’m migrating from Laravel’s legacy test tools?
Yes, TestBench is built on Orchestral Testbench (a fork of Laravel’s legacy tools), so it’s a natural upgrade path. However, if you’re modernizing your stack, evaluate Laravel’s native testing tools or PEST, as they may offer better long-term support.
How do I test database interactions in TestBench? Does it support migrations or factories?
TestBench integrates with Laravel’s database testing utilities. Use `createApplication()` to bootstrap the app, then leverage Laravel’s `DatabaseMigrations` or `DatabaseTransactions` traits for migrations and factories. Example: `use CreatesApplication;` in your test class.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport