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

Double Laravel Package

jasonmccreary/double

Double is a Laravel package by Jason McCreary for creating test doubles. It lets you swap real services for lightweight, configurable fakes that record method calls and return stubbed responses, keeping your test suite fast and free of heavy mocking boilerplate.

View on GitHub
Deep Wiki
Context7

Double is a lightweight Laravel package for creating test doubles in your test suite. Rather than writing repetitive anonymous classes or over-configuring mocks, you generate a stand-in object and stub only the methods your code actually calls—keeping tests readable and focused on behavior.

It fits naturally into PHPUnit and Pest workflows, follows Laravel conventions, and removes mocking ceremony so you spend less time on setup and more on assertions.

  • Create test doubles for classes and interfaces
  • Stub only the methods you need
  • Eliminate boilerplate anonymous classes
  • Works with PHPUnit and Pest
  • Minimal, fluent API
Frequently asked questions about Double
What is jasonmccreary/double used for in Laravel tests?
Double is a PHP test-double library for creating mocks with a simple, expressive API. In Laravel projects it reduces mocking boilerplate in PHPUnit or Pest tests so dependencies can be isolated cleanly. It is a developer-experience tool for tests, not a runtime package.
How do I install and configure Double in a Laravel project?
Install it with Composer as a dev dependency, typically using composer require --dev jasonmccreary/double. It is a plain PHP library with no service provider, config file, published assets, or container bindings to register. You can use it alongside your existing PHPUnit or Pest tests without changing Laravel bootstrapping.
Does Double work with PHPUnit and Pest, and which versions are supported?
Double is designed to work alongside PHPUnit and Pest rather than replacing either test runner. The provided context does not list exact supported major versions, so confirm PHPUnit 10/11/12 and Pest 2/3 compatibility with the maintainer. Also check that your lowest CI PHP version meets the library's PHP floor.
Does Double replace Mockery or PHPUnit's createMock()?
Double is a substitutive developer-experience alternative to Mockery and PHPUnit createMock(), not a missing capability in Laravel. Laravel already ships Mockery and pre-wires it in its TestCase, so the real question is whether Double's ergonomics justify a switching cost. You can keep existing mocks and adopt Double selectively.
Can I use Double and Mockery in the same Laravel test suite?
Coexistence is technically viable because the libraries use distinct namespaces and are not expected to collide on global state. That makes a partial migration or pilot possible without rewriting the whole suite. Publish a short convention so mixed adoption does not create inconsistent mocking styles.
Does Double support final classes, readonly classes, enums, union types, and intersection types?
The context does not confirm support for these specific PHP language features. Final classes, readonly classes, enums, and union or intersection types are where mocking libraries diverge most, so test them in a small spike. Ask the maintainer for an explicit feature matrix before standardizing.
Does Double support spies, partial mocks, argument matchers, and consecutive return values?
The context describes a simple, expressive API but does not state whether it covers spies, partial mocks, argument matchers or callbacks, and consecutive-return sequences. It may be a deliberately narrower API focused on common mocking cases. Confirm these features against your existing complex tests before migrating them.
Does Double integrate with Laravel facade mocking, $this->mock(), container swaps, and job or event fakes?
The context does not explicitly confirm Laravel-specific integrations such as facade mocking, $this->mock() and $this->partialMock(), container instance swaps, or queued job and event fakes. Because Double works alongside PHPUnit and Pest, you can likely keep Laravel's built-in helpers where needed. Validate these patterns in one or two low-traffic test directories first.
How do I migrate a large existing Laravel test suite to Double?
Treat Double as an additive pilot, not a full replacement: add it to require-dev, introduce it in one or two low-traffic test directories, and leave Mockery and createMock() untouched elsewhere. Rewriting a large suite is rarely justified by developer-experience gains; the ROI is mostly in new test authorship. Document that new tests in chosen namespaces use Double while legacy tests are not rewritten opportunistically.
Is Double safe for production and what are the maintenance risks?
Double is a require-dev dependency, so it never ships to production and adds no runtime bytes; failures appear as red CI builds, not user incidents. The material risks are a single maintainer, a small adopter base, and version coupling to PHPUnit and Pest majors. The Repository: unknown field and the 2026-10-01 release date are data-quality flags to resolve before supply-chain sign-off. Verify the canonical repository, CI status, Packagist namespace, and release cadence before onboarding.
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.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections