Summary
PHPUnit currently provides:
withParameterSetsInOrder() (strict ordering)
withParameterSetsInAnyOrder() (no ordering constraints)
There is no way to express partial ordering, where some calls must occur at specific positions while others may occur in any order.
Proposal
Introduce: withParameterSetsInPartialOrder() - partially ordered arguments
$mock->expects($this->exactly(4))
->method('dispatch')
->withParameterSetsInPartialOrder(
$this->fixed($a),
[$b],
[$c],
$this->fixed($d),
);
fixed(...) parameter sets must match exactly at their declared position
- other parameter sets may match remaining positions in any order
- all parameter sets must be matched exactly once
This allows expressing common patterns such as:
- setup → arbitrary operations → cleanup
- fixed first/last calls with flexible middle
I am open to alternative API designs if there is a better way to express this.
Summary
PHPUnit currently provides:
withParameterSetsInOrder()(strict ordering)withParameterSetsInAnyOrder()(no ordering constraints)There is no way to express partial ordering, where some calls must occur at specific positions while others may occur in any order.
Proposal
Introduce:
withParameterSetsInPartialOrder()- partially ordered argumentsfixed(...)parameter sets must match exactly at their declared positionThis allows expressing common patterns such as:
I am open to alternative API designs if there is a better way to express this.