seec/phpunit-consecutive-params
Bring back PHPUnit’s removed withConsecutive behavior. This lightweight dev helper provides a drop-in replacement via a trait, letting you assert different parameter sets across consecutive mock calls using ->with(...$this->withConsecutive(...)).
withConsecutive() method, requiring minimal architectural changes. It adheres to PHPUnit’s testing patterns without introducing new dependencies or altering core logic.phpunit.php config) and does not conflict with Laravel-specific testing utilities (e.g., RefreshDatabase, Mockery).--dev) and usage via use ConsecutiveParams trait. No Laravel service provider or facade required.withConsecutive() can be migrated with minimal syntax changes (e.g., wrapping calls in with(...$this->withConsecutive(...))).withConsecutive(), migration effort scales with test volume. Automated refactoring tools (e.g., PHPStorm, pcre2 regex) can accelerate updates.withConsecutive()? Prioritize migration for high-impact tests.withConsecutive() (e.g., via a feature flag)?phpunit.xml, tests/TestCase). Works alongside:
Mockery or PHPUnit mocks.RefreshDatabase).createApplication()).composer.json.use in test files).--parallel mode.grep -r "withConsecutive" tests/ to identify affected tests.// Before (deprecated)
->withConsecutive([1, 2], [3, 4]);
// After
->with(...$this->withConsecutive([1, 2], [3, 4]));
\.withConsecutive\(([^)]*)\) → ->with(...$this->withConsecutive($1))
phpunit --coverage to ensure test coverage isn’t inadvertently reduced.withConsecutive usage.TestCase (no method conflicts).createMock() (not Mockery’s mock()).v1.1.x; otherwise, use ^1.2.withConsecutive calls entirely (if no longer needed).README.md or CONTRIBUTING.md to note the trait’s usage for new devs.withConsecutive() (e.g., via a PR or RFC).use SEEC\PhpUnit\Helper\ConsecutiveParams;
use Tests\TestCase;
class MyTest extends TestCase {
use ConsecutiveParams;
// ...
}
| Risk | Mitigation | Detection |
|---|---|---|
| Test breakage | Run full suite post-migration. | CI/CD red build. |
| Syntax errors | Use regex + IDE previews before commit. | Local test runs. |
| PHP version mismatch | Pin package version in composer.json. |
CI linting (e.g., composer validate). |
| Trait conflicts | Avoid naming collisions (e.g., use order). |
Static analysis (PHPStan). |
How can I help you explore Laravel packages today?