[wp-trac] [WordPress Trac] #53364: Tests: Reduce usage of assertEquals for 5.9
WordPress Trac
noreply at wordpress.org
Wed Oct 20 02:14:11 UTC 2021
#53364: Tests: Reduce usage of assertEquals for 5.9
-------------------------------------------+---------------------
Reporter: desrosj | Owner: (none)
Type: task (blessed) | Status: new
Priority: normal | Milestone: 5.9
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: php8 has-patch has-unit-tests | Focuses:
-------------------------------------------+---------------------
Comment (by costdev):
= Report
==== Stage 0
Changes: None
Results for `assertEquals()`: 528 results in 118 files. ( -0 )
==== Stage 1
Changes:
- PR 1768 - Replace `assertEquals()` with `assertSame()` where tests pass
with no other code requiring changes.
Results for `assertEquals()`: 519 results in 118 files. ( -9 )
Status: The PR is ready for review.
==== Stage 2
Changes:
- All of the above (for calculations, not for the patch)
- Cast `ceil()` to `int` throughout non-third party `.php` files in `src`.
- Change `assertEquals()` to `assertSame()` for relevant tests.
Results for `assertEquals()`: 493 results in 115 files. ( -26 )
Notes:
- Remaining tests that compare an `int` to a `float` using
`assertEquals()` are not affected by the `ceil()` change. As a result,
these have been left until **Stage 6** for investigation.
Status:
- Pending feedback on the approach.
- The patch is prepared and with some self-review, will be ready for PR.
==== Stage 3
Changes:
- All of the above (for calculations, not for the patch)
- For most assertions that compare a raw `int` to a `string` response,
wrap the expected value in `''`.
- For some in `tests/phpunit/tests/image/meta.php`, these are asserting
camera shutter speed in EXIF data. These have been casted to `string`
using, for example, `(string) ( 1 / 40 )`.
Results for `assertEquals()`: 402 results in 112 files. ( -91 )
Status:
- Pending feedback on the approach.
- The patch is prepared and with some self-review, will be ready for PR.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53364#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list