-
-
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
Improve the failure description of StringContains
-based assertions when the strings are encoded differently
#5505
Improve the failure description of StringContains
-based assertions when the strings are encoded differently
#5505
Conversation
Thank you for your contribution. I appreciate the time you invested in preparing this pull request so far. However, this is not yet ready to be merged. Please fix the failing the tests. Please follow the workflow for pull requests, specifically:
|
Hey @sebastianbergmann, thanks for authorising the workflow run and the kind message. Odd, those tests passed for me locally on PHP 8.2; I'll see if I can reproduce the issue now. Are tests passing on one machine and not another common with this pipeline? Re:
I specifically chose my commit name to be two-plus-two-equals-five and email to be the one autogenerated by Github as it obscures my real one after reading that in the CONTRIBUTING.md file. I'll also look at updating the PHPUnit documentation if this PR gets merged (although, on initial viewing, it looks like the assertion outputs are autogenerated by a script on/near release - which is cool). Thanks again |
Update: It looks like it was late-night human error. I've pushed the fix. @sebastianbergmann can you please reauthorise the workflow run? |
Codecov Report
@@ Coverage Diff @@
## main #5505 +/- ##
============================================
+ Coverage 87.34% 87.35% +0.01%
- Complexity 6327 6335 +8
============================================
Files 676 676
Lines 20256 20286 +30
============================================
+ Hits 17692 17721 +29
- Misses 2564 2565 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I try to avoid anonymous commits as much as possible. As far as this PR is concerned, I do not think that it will be a problem. |
Thanks @sebastianbergmann, and thank you for rerunning the pipeline. Is there anything else you need me todo? I'm happy to answer any questions you may have :) |
…n#5128. To consider if it should be its own test (as want to write assertions that prove that each string really is the encoding my comments say they - I think it improves readability)
…ake the expected string lines longer. Renamed existing provider to distinguish between the two
…the Assert class level) "needle and haystack" convention as was hard to follow this test class otherwise. Named all provider test cases to make it easier to understand what each one checks. Drove out failureDescription() changes to include detected encoding and length value for both needle and haystack
…ding = mb_detect_order() yet psalm throws an error with that change. I set param to = null instead as that is its default and its comment says the method will call mb_detect_order() under the hood
…hod keeps doing it)
96d90b6
to
a848240
Compare
StringContains
-based assertions when the strings are encoded differently
Thanks @sebastianbergmann! |
This PR is a proposed improvement to the existing failure message being generated by the StringContains Constraint based on the discussions about it in the #5128 thread.
For those not familiar with the issue, this improvement specifically adds additional information (the detected string encoding + string length) to the failure message returned for debugging purposes.
Reason for doing so: the console outputs tend to hide the visual difference between two strings when there are different but similar encoding characters (i.e. Unicode's 'thin spaces' verses ASCII's "regular" spaces <-- more on this in the new tests written below).
Example of test output after changes:
Example of test output before changes:
Here is the test that generated this output (note that the 'needle' string uses a thin space character for the space between the two words, whereas the haystack uses a regular space instead):
Notes to reviewer:
⚛ - this PR was (primarily) written atomically, so reviewing each commit chronologically is recommended for the best review experience
📝 - this PR's commits contained details of the reasonings for technical decisions made - so if you find yourself thinking: "why did they do that?", please read the commit messages 😊
🐤 - this is my first PR for PHPUnit so I very much welcome advice / steering on conventions etc