browser
browser copied to clipboard
Confusing `assertJsonMatches` exception message when arrays are equal but not same
Hello,
I just faced an issue with assertJsonMatches
method (note for search engine: which calls json()->assertMatches
) can throw a weird exception message : (array:assoc)" to be the same as "(array:assoc)".
It turns out that's because I didn't ordered my array the same way the api endpoint tested returns its.
Value returned by the API:
{
"errors": {
"last_name": ["Invalid value"],
"first_name": ["Invalid value"],
}
}
Test:
assertJsonMatches('errors', [
'first_name' => ['Invalid value'],
'last_name' => ['Invalid value'],
]); // This will throw the exception message above
The same issue applies for multidimensional arrays.
I hope this can be easily fixed. I have no idea how for now. :exploding_head:
Thank you!