Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
ResourceTestBase uses assertSame for asserting values. This is breaks comparisons of stringified floats, making the test class hard to use.
assertEquals also returns a generated difference between the values, which assertSame does not. This would improve the DX for comparing JSON:API documents.
See #3128322: Filtering variations over JSON:API is always access false.
Steps to reproduce
Use a decimal field with precision storage of 6. 4.00 will serialize to JSON as 4.0 but return from MySQL as 4.00000
Proposed resolution
Switch from assertSame to assertEquals
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#3 | resourcetestbase_sho-3163853-2.patch | 2.94 KB | mglaman |
Comments
Comment #2
mglamanComment #3
mglamanRetitling. It does not need to be changed everywhere. Just whenever it is comparing values from normalized field values.
Comment #5
Kristen PolThanks for the issue and patch. Marking RTBC since:
1) Patch applies cleanly to 9.2.
2) Tests pass.
3) Additional tests aren't needed since these are tests :)
4) Issue summary and example are clear.
Comment #7
catchCommitted a6258c8 and pushed to 9.2.x. Thanks!