Add equals method to collection #23544
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey, first time contributing to the framework, hope this is not too bad and sorry if it is
Similar to the is() method for model comparison I wanted to add an equals method to compare two collections based on their values.
My need to add this comes from testing that the collection a view received is the same as the one you created in a test, this method would allow a simple check like so:
If it is a single model you can easily do the comparison with the is() method, however I believe there is nothing similar for collections.
The way I do the check is by using the diff method in collections and verifying that the count equals 0 in both ways (that means that a is equal to b and that b is equal to a, because based on the way diff works it can lead to different results).
Thanks and again, sorry if I missed anything or if my implementation is too naive.