Standardize usages of PHPUnit's assertEquals()#1868
Merged
williamjallen merged 1 commit intoKitware:masterfrom Dec 10, 2023
Merged
Standardize usages of PHPUnit's assertEquals()#1868williamjallen merged 1 commit intoKitware:masterfrom
assertEquals()#1868williamjallen merged 1 commit intoKitware:masterfrom
Conversation
williamjallen
requested changes
Dec 6, 2023
0b5cacb to
61bf790
Compare
williamjallen
approved these changes
Dec 10, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
According to the PHPUnit docs for
assertEquals(), the first argument to the function should be the expected output, and the second argument should be the actual value as produced by the test. Currently, we have multiple places in the codebase where this ordering of the arguments is not respected. Calling this function with the arguments swapped can lead to confusion when debugging failed tests, as PHPUnit's error messages present failed comparisons in terms of an "expected" and an "actual" value.The changes in this PR correct the instances where we use the wrong ordering (except for the file
tests/Feature/Monitor.phpwhich is being improved in PR #1826).There are many other PHPUnit assertion functions that follow this argument format and are used in our test suites. Future PRs will correct the cases for those functions where the argument ordering is not respected as well.
It would also be nice if we could add tools to automatically enforce this, in order to prevent this from happening in the future and improve our development experience.