-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Undocumented backwards compatibility break with assertEqualsCanonicalizing #5967
Comments
Seems to be fallout from the fix for this issue: #5019 |
The core issue seems to be a change to fix sebastianbergmann/comparator#112 in release https://github.com/sebastianbergmann/comparator/releases/tag/5.0.2 public function test_comparator(): void
{
$this->assertEqualsCanonicalizing(
[
0 => 1,
1 => 2,
2 => 3,
],[
0 => 1,
1 => 2,
3 => 3,
]
);
} will fail with:
Which is a breaking change. It kind of defeat the purpose of the Canonicalizing |
@olivier-zenchef The main question is: what is an "array"? "PHP array" is not an "array" known from other languages. In your example Of course @sebastianbergmann may change |
@mgleska one usage of My point is that it's a breaking change because a key behaviour changed without a major step in version. Our tests are roughly: $expectation = [1, 2, 3];
$startingData = [1, 2, 3, 4, 5];
// Will produce [0 => 1, 1 => 2, 3 => 3] because possibility 2 was culled
$result = $myService->computeSomethingByCullingAnArray($startingData);
// Will now fail
$this->assertEqualsCanonicalizing($result, $expected); During the Now we want to update our phpunit version but it breaks several key tests about our key calculations.
In both cases this is not what we expected when upgrading a minor version. |
To make it clear, there are two points being argued for here:
We can still discuss what to do about point 2 and whether we want to revert the behavior to the old one for numerical arrays, even if their keys are out of order. But point 1 should not be up for discussion as that's simple fact. |
For the record and google searchers:
You have to do both as phpunit require comparator from 5.0.2 starting tag 10.5.30. |
sebastian/comparator 5.0.3 and sebastian/comparator 6.1.1 have been released and revert sebastianbergmann/comparator#113. |
@sebastianbergmann thanks for listening to our feedback and for the quick fix 🙏 |
Summary
Before, assertEqualsCanonicalizing would succeed on the following code:
This was great when we were, for instance, comparing a list of permission names in Drupal. We don't care which numerical keys they have, we only care about all of the names being there. Now, it chokes on the numerical keys being different, when they don't neatly increment one after another.
Current behavior
How to reproduce
Try the code above
Expected behavior
That my tests would keep going green like they used to, rather than fail after updating phpunit and not seeing anything about this in the release notes :)
The text was updated successfully, but these errors were encountered: