-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New array assertions #6477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
New array assertions #6477
Conversation
|
@Seldaek @theofidry I would greatly appreciate your feedback on this as soon as possible. For the purposes of this review, I suggest focusing on the test cases rather than the implementation. @staabm Maybe this is of interest to you as well. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6477 +/- ##
============================================
+ Coverage 96.02% 96.03% +0.01%
- Complexity 7367 7395 +28
============================================
Files 798 801 +3
Lines 22664 22753 +89
============================================
+ Hits 21762 21851 +89
Misses 902 902 ☔ View full report in Codecov by Sentry. |
theofidry
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question mark for me looking at the tests is what you expect the behaviour to be for objects with the same structure but of a different class.
I would expect them to be different, but it is not obvious this is what is expected when looking at the tests.
|
Looking forward to it 😄 |
I would expect that, too. As does PHP: <?php declare(strict_types=1);
final class A
{
private string $foo = 'bar';
}
final class B
{
private string $foo = 'bar';
}
$a = [new A];
$b = [new B];
var_dump($a == $b); |
This implements the
assertArraysAreIdentical(),assertArraysAreIdenticalIgnoringOrder(),assertArraysHaveIdenticalValues(),assertArraysHaveIdenticalValuesIgnoringOrder(),assertArraysAreEqual(),assertArraysAreEqualIgnoringOrder(),assertArraysHaveEqualValues(), andassertArraysHaveEqualValuesIgnoringOrder()assertions as requested in #6423.The implementation follows the specification in #6423 (comment).
It is worth noting that the implementation uses the
==operator for the new equality-related assertions and does not delegate the comparison to a chain ofComparatorobjects, as is the case withassertEquals(), for example.