Make WordPress Core

Opened 10 months ago

Closed 7 months ago

#58956 closed task (blessed) (fixed)

Tests: Reduce usage of assertEquals for 6.4

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


10 months ago
#1

  • Keywords has-patch has-unit-tests added

Trac ticket: https://core.trac.wordpress.org/ticket/58956

Some of the assertEquals and assertSame calls that compare array/iterable counts can be replaced with assertCount 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.

This ticket was mentioned in PR #5353 on WordPress/wordpress-develop by @jorbin.


8 months ago
#2

Trac ticket: https://core.trac.wordpress.org/ticket/58956

This fixes the PHPCS issues in #4968.

#3 @jorbin
8 months ago

In 56746:

Tests: Reduce usage of assertEquals

Replaces assertSame with assertCount in a number of tests.

Props ayeshrajans, jorbin.
See #58956.

@jorbin commented on PR #4968:


8 months ago
#4

Thanks, this was committed in https://core.trac.wordpress.org/changeset/56746

@jorbin commented on PR #5353:


8 months ago
#5

Thanks, this was committed in https://core.trac.wordpress.org/changeset/56746

#6 @hellofromTonya
7 months ago

  • Resolution set to fixed
  • Status changed from new to closed

#59655 is now open for 6.5. With 6.4 RC1 happening in a couple of hours and all patches committed, closing this ticket for the cycle. Can be reopened if additional changes are needed or to be backported to the 6.4 branch.

Note: See TracTickets for help on using tickets.