phpunit
phpunit copied to clipboard
Using constraints in arrays evaluated with isEqual
It would be quite handy to use constraints within array values when using isEqual, like so:
$mock = $this->createMock(SomeClass::class);
$mock
->method('doSomething')
->with([
'key' => $this->isType('string'),
'value' => 'some value',
]);
$mock->doSomething([
'key' => 'some string',
'value' => 'some value',
]);
This currently fails since the underlying comparator does not execute the constraint with the actual value. Is this achievable with some other constraint than isEqual perhaps?
Is this something you would consider adding if given a pull request with an initial implementation, or would you recommend using the callback constraint for this?