- 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.