Callback
constraint does not handle variadic arguments correctly when used for mock object expectations
#5891
Labels
feature/test-doubles
Test Stubs and Mock Objects
type/bug
Something is broken
version/10
Something affects PHPUnit 10
version/11
Something affects PHPUnit 11
Summary
I need to assert the number of elements being passed as an argument on a mocked method for a mocked service.
The argument being passed is an spread operator, and I experience a weird behaviour when unpacking the array.
It always unpack the array as 1 element even the argument passed is an array with multiple elements, it just returns one.
Current behavior
Unpacking spread operator when trying to assert the expected arguments being passed to a mocked method returns always 1 element of the array being passed instead of the full array.
How to reproduce
//Class being mocked:
//Class being used:
//Test:
Expected behavior
Inside the self::callback function, when counting the number of elements inside of the array passed as spread operator should return the actual number of elements.
For example:
The text was updated successfully, but these errors were encountered: