- How do I install digitalrevolution/phpunit-extensions in a Laravel project?
- Install it as a development dependency with composer require --dev digitalrevolution/phpunit-extensions. The current release targets PHP 8.1+, PHPUnit 10 through 13, and Symfony 6/7/8 components for its Symfony helpers. In a Laravel app, confirm your composer.json PHP and PHPUnit constraints before adding it so you do not force an unwanted PHPUnit upgrade.
- Is digitalrevolution/phpunit-extensions compatible with Laravel?
- There is no Laravel-specific compatibility matrix; the package is a PHPUnit utility library with Symfony-oriented helpers. Laravel projects can use the PHPUnit-centric features if their PHP, PHPUnit, and Symfony component constraints match, but Laravel's HTTP, database, and validation helpers are separate. Treat Symfony traits as opt-in only when your app already uses the relevant Symfony components.
- Which PHPUnit versions does this package support?
- The current release targets PHPUnit 10 through 13, so Laravel projects still on PHPUnit 9 will need to plan an upgrade. The withConsecutive replacement is specifically aimed at code migrating from PHPUnit 9.5 or earlier to PHPUnit 9.6 and newer. Check the package's composer.json for exact constraints before upgrading your test suite.
- How do I replace withConsecutive after upgrading to PHPUnit 10 in Laravel?
- PHPUnit 10 removed withConsecutive, so the package provides a consecutive() helper that you spread into with(). For example, replace withConsecutive([123, 'foobar'], [456]) with with(...consecutive([123, 'foobar'], [456])). This keeps existing mock expectations working while you migrate, but you should still review tests for behavior changes in PHPUnit 10.
- Can I use AbstractControllerTestCase for Laravel controllers?
- No, AbstractControllerTestCase is built around Symfony's controller container, security, form, routing, and response APIs. Laravel controllers use the Laravel container, middleware, facades, and HTTP test helpers, so this trait will not work directly without a Symfony bridge or custom adapter. For normal Laravel controller tests, use Laravel's own HTTP tests instead.
- Can I use AbstractConstraintValidatorTestCase with Laravel validation?
- No, AbstractConstraintValidatorTestCase targets Symfony's Validator component and ConstraintViolationBuilder assertions. Laravel's validator has different classes and violation APIs, so the trait is not a drop-in replacement for Laravel validation tests. It may be useful only if your Laravel app deliberately uses Symfony Validator through a bridge.
- What are the requirements for image and PDF assertions?
- ImageTestTrait and PdfTestTrait depend on Imagick, and rendering-based assertions typically also require Ghostscript. As of v1.14.0, PDF assertions support both TCPDF and TcLibPdf, reducing PDF-engine lock-in. Your CI environment must have these native tools installed even though the package itself is a dev dependency.
- Does ClockTestTrait interfere with Laravel tests like RefreshDatabase?
- ClockTestTrait can modify global time state, which may interact with Laravel features such as RefreshDatabase, model timestamps, and queued jobs. Use it in isolated tests and make sure the clock is restored after each test. If you see order-dependent failures, check whether a test left the clock mocked.
- What are alternatives to this package for Laravel testing?
- For most Laravel projects, Laravel's built-in HTTP, database, queue, and time-travel helpers plus Mockery cover common testing needs. If you only need a withConsecutive replacement, you can also write custom expectation callbacks or use Mockery argument matching. This package is most compelling when you also need its Symfony bridge traits or image/PDF assertions.
- Is the package actively maintained and safe for production?
- The package is actively maintained, with v1.14.0 shipping soon after v1.13.3 as an additive PDF feature release. It is a development dependency, so it does not ship to production runtime, but its Symfony focus means Laravel-specific issues may not be prioritized. Pin a version in CI and review changelogs before upgrading.