Skip to content
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

assertArrayIsIdenticalToArrayOnlyConsideringListOfKeys() does not correctly handle array order #5729

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Mar 10, 2024

Follow up on #5716.

Sorry, I screwed up.

While the fix in #5716 correctly fixes the handling of array keys to be in line with PHP itself, it broke the differentiation between isEqual and isIdentical as the arrays were now being recreated in the order of the keys passed to the $keysToBeConsidered parameter.

This is not problematic for the assertArrayIsEqualToArrayOnlyConsideringListOfKeys() assertion as the array order is not relevant there.

However, it is problematic for the assertArrayIsIdenticalToArrayOnlyConsideringListOfKeys() assertion, where the array order is relevant.

This commit fixes it.

Includes unit test safeguarding the fix.

And while the assertArrayIs*ToArrayIgnoringListOfKeys() assertions are not affected, I've also included a unit test for the issue for those assertions, just to be on the safe side.

Follow up on 5716.

Sorry, I screwed up.

While the fix in 5716 correctly fixes the handling of array keys to be in line with PHP itself, it broke the differentiation between `isEqual` and `isIdentical` as the arrays were now being recreated in the order of the keys passed to the `$keysToBeConsidered` parameter.

This is not problematic for the `assertArrayIsEqualToArrayOnlyConsideringListOfKeys()` assertion as the array order is not relevant there.

However, it is problematic for the `assertArrayIsIdenticalToArrayOnlyConsideringListOfKeys()` assertion, where the array order is relevant.

This commit fixes it.

Includes unit test safeguarding the fix.

And while the `assertArrayIs*ToArrayIgnoringListOfKeys()` assertions are not affected, I've also included a unit test for the issue for those assertions, just to be on the safe side.
Copy link

codecov bot commented Mar 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.95%. Comparing base (dcb95b9) to head (ffbc040).
Report is 1 commits behind head on 11.0.

Additional details and impacted files
@@             Coverage Diff              @@
##               11.0    #5729      +/-   ##
============================================
- Coverage     89.95%   89.95%   -0.01%     
+ Complexity     6464     6460       -4     
============================================
  Files           683      683              
  Lines         19591    19586       -5     
============================================
- Hits          17624    17619       -5     
  Misses         1967     1967              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sebastianbergmann sebastianbergmann added type/bug Something is broken feature/assertion Issues related to assertions and expectations labels Mar 10, 2024
@sebastianbergmann sebastianbergmann merged commit a6eedd5 into sebastianbergmann:11.0 Mar 10, 2024
25 checks passed
@sebastianbergmann sebastianbergmann changed the title assertArrayIsIdenticalToArrayOnlyConsideringListOfKeys(): bug fix - array order not correctly handled assertArrayIsIdenticalToArrayOnlyConsideringListOfKeys() does not correctly handle array order Mar 10, 2024
@jrfnl jrfnl deleted the feature/assertarrayidentical-bugfix branch March 10, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/assertion Issues related to assertions and expectations type/bug Something is broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants