Opened 2 months ago
Last modified 2 weeks ago
#64895 new task (blessed)
Tests: Reduce usage of assertEquals for 7.1
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 7.1 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Build/Test Tools | Keywords: | has-patch has-unit-tests |
| Focuses: | Cc: |
Description
The assertEquals() test method does not check that the types of the expected and actual values match. This can hide subtle bugs especially when the values are falsey.
Tasks:
- Switch to using
assertSame()when the type of the value in the assertion is important - Replace overall usage of
assertEquals()with type-strict assertion methods, with the aim of potentially removing its usage altogether
To help ease the effort of merging tests, changes should also be made upstream in the Gutenberg repository.
Follow-up to:
Change History (1)
This ticket was mentioned in PR #11707 on WordPress/wordpress-develop by @shreyasikhar26.
2 weeks ago
#1
- Keywords has-patch has-unit-tests added
Note: See
TracTickets for help on using
tickets.
## PR Description
assertSame()instead ofassertEquals()to enforce strict type comparisons.(int)cast forpost_authorin the bulk edit test to avoid false positives due to string/integer mismatches.Trac ticket: https://core.trac.wordpress.org/ticket/64895
## Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Used for: Find the files where
assertEquals()can be replaced withassertSame().