phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

Canonicalize by sorting keys instead of values

Open m-vo opened this issue 5 years ago • 0 comments

Using assertEqualsCanonicalizing effectively uses sort() to canonicalize arrays. I fail to see where this might become helpful in a unit test scenario (unidentifiable values whose order doesn't matter)? On the other hand (unordered) key/value collections (i.e. arrays with non-integer keys) are a common thing which would need to be canonicalized with ksort() instead and currently are cumbersome to compare against each other.

Maybe I'm missing on the design decision behind that. :slightly_smiling_face: Or in other words: What about supporting the latter case out of the box as well?

m-vo avatar Sep 12 '20 11:09 m-vo