Make WordPress Core

Opened 2 months ago

Last modified 2 weeks ago

#64895 new task (blessed)

Tests: Reduce usage of assertEquals for 7.1

Reported by: desrosj's profile desrosj 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

## PR Description

  • Updates multiple PHPUnit tests to use assertSame() instead of assertEquals() to enforce strict type comparisons.
  • Adds an explicit (int) cast for post_author in the bulk edit test to avoid false positives due to string/integer mismatches.
  • Touches tests covering admin bulk edit behavior, REST API endpoints (attachments, global styles, wp-abilities), and theme preview hooks—no production/runtime code changes.

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 with assertSame().

Note: See TracTickets for help on using tickets.