- How do I install this package for Laravel PHPUnit tests?
- Run `composer require --dev seec/phpunit-consecutive-params` in your project root. The package is designed as a dev dependency and integrates directly with Laravel’s PHPUnit test suite without requiring additional configuration.
- Will this work with Laravel’s built-in TestCase?
- Yes, the trait is fully compatible with Laravel’s `TestCase` and won’t conflict with any Laravel-specific testing utilities like `RefreshDatabase` or `createApplication()`. Just add `use ConsecutiveParams` to your test class.
- What PHPUnit versions does this support?
- This package works with PHPUnit 9.x and 10.x, which aligns with Laravel 9/10’s default PHPUnit versions. Ensure your `composer.json` doesn’t enforce an older or newer PHPUnit version that would cause conflicts.
- How do I migrate existing `withConsecutive()` calls?
- Wrap your existing calls in `with(...$this->withConsecutive(...))`. For example, replace `$mock->withConsecutive([1, 2], [3, 4])` with `$mock->with(...$this->withConsecutive([1, 2], [3, 4]))`. Use regex search/replace in your IDE to automate this.
- Does this package support PHP 8.3 and newer?
- Yes, the package officially supports PHP 8.1+, including 8.3. Laravel 10+ requires PHP 8.1+, so this package will work seamlessly with modern Laravel versions. Check your CI environment to ensure PHP version alignment.
- Can I use this with PestPHP instead of PHPUnit?
- Yes, but you’ll need to explicitly include the trait in your Pest test files since Pest doesn’t inherit PHPUnit’s TestCase. Add `use ConsecutiveParams;` to your test file, and the syntax remains identical to PHPUnit.
- Will this slow down my test suite?
- No, the trait introduces negligible overhead. It’s a lightweight wrapper around PHPUnit’s mocking logic, so your test execution time should remain unchanged. Benchmark if you’re running CI-heavy workflows, but expect minimal impact.
- What if PHPUnit reinstates `withConsecutive()` in the future?
- Monitor PHPUnit’s GitHub for updates. If `withConsecutive()` is reintroduced, you can either remove this package or keep it as a fallback. The package’s design ensures backward compatibility, so you won’t break existing tests.
- Does this work with Mockery alongside PHPUnit?
- Yes, but ensure your mocks are created using PHPUnit’s `createMock()` (not Mockery’s `mock()`). The trait is designed for PHPUnit’s mocking system, so Mockery-specific mocks won’t benefit from this feature.
- How do I handle tests that use `withConsecutive()` in legacy PHP 7.4 projects?
- Pin to version `1.1.x` of this package if you’re using PHP 7.4, as newer versions require PHP 8.1+. For Laravel projects, this is less relevant since Laravel 9+ drops PHP 7.4 support, but it’s worth noting for older codebases.