Opened 14 months ago
Closed 12 months ago
#58956 closed task (blessed) (fixed)
Tests: Reduce usage of assertEquals for 6.4
Reported by: | SergeyBiryukov | Owned by: | |
---|---|---|---|
Milestone: | 6.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
Follow-up to:
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 backporting tests, changes should also be made upstream in the Gutenberg repository.
Change History (6)
This ticket was mentioned in PR #4968 on WordPress/wordpress-develop by @ayeshrajans.
14 months ago
#1
- Keywords has-patch has-unit-tests added
This ticket was mentioned in PR #5353 on WordPress/wordpress-develop by @jorbin.
12 months ago
#2
Trac ticket: https://core.trac.wordpress.org/ticket/58956
This fixes the PHPCS issues in #4968.
12 months ago
#4
Thanks, this was committed in https://core.trac.wordpress.org/changeset/56746
12 months ago
#5
Thanks, this was committed in https://core.trac.wordpress.org/changeset/56746
Trac ticket: https://core.trac.wordpress.org/ticket/58956
Some of the
assertEquals
andassertSame
calls that compare array/iterable counts can be replaced withassertCount
calls to indicate the intent better. I hope I'm not derailing the ticket with this PR, but hopefully you will find it relevant in the same context.