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() functionality without rewriting existing test cases, reducing technical debt.withConsecutive() was previously essential.Adopt if:
withConsecutive() (e.g., >20% of mock assertions).Look elsewhere if:
withConsecutive() (opportunity cost of dependency outweighs benefits)."This package lets us keep using a critical testing pattern (withConsecutive) that PHPUnit removed, without rewriting thousands of lines of tests. It’s a low-risk, high-reward fix for test suite stability—especially as we upgrade PHP versions. The cost? Minimal: a single Composer dependency that saves dev time and reduces regression risks during upgrades. Think of it as ‘insurance’ for our test infrastructure."
Key Outcomes:
*"PHPUnit deprecated withConsecutive(), but this package restores it as a drop-in trait. Here’s why it’s worth adopting:
use ConsecutiveParams to your test classes.Use Case Example:
// Before (broken in newer PHPUnit):
$mock->method('process')->withConsecutive([1], [2], [3]);
// After (with this package):
$mock->method('process')->with(...$this->withConsecutive([1], [2], [3]));
Tradeoff: GPL-3.0 license (check legal compliance). Otherwise, it’s a no-brainer for teams stuck with legacy tests."*
Call to Action:
composer.json as a dev dependency.How can I help you explore Laravel packages today?