willReturnCallback()
does not pass unknown named variadic arguments to callback
#5455
Labels
feature/test-doubles
Test Stubs and Mock Objects
type/change-in-php-requires-adaptation
A change in PHP requires a change so that existing PHPUnit functionality continues to work
Summary
Mocks for methods that accept var args do not passed unknown named variadic arguments to the callback in
willReturnCallback()
. AFAIK this should be supported since PHP 8.0.0.I believe the issue exists because the mocks use
func_*()
for getting the passed arguments, but those functions no longer return all arguments. See func_get_args() for details.Current behavior
Only indexed arguments are passed.
How to reproduce
Here's two passing tests for unmocked cases and a failing test that uses a mock.
tests/Support/VarArger.php
tests/WithReturnCallbackTest.php
The mock class looks like this:
Expected behavior
All arguments should be passed to the callback.
The text was updated successfully, but these errors were encountered: