What is a good way to assert that two arrays of objects are equal, when the order of the elements in the array is unimportant, or even subject to change?
What is a good way to assert that two arrays of objects are equal, when the order of the elements in the array is unimportant, or even subject to change?
If values are just int or strings, and no multiple level arrays....
Why not just sorting the arrays, convert them to string...
$mapping = implode(',', array_sort($myArray));
$list = implode(',', array_sort($myExpectedArray));
... and then compare string:
$this->assertEquals($myExpectedArray, $myArray);