Make WordPress Core

Opened 4 months ago

Closed 3 months ago

Last modified 3 months ago

#60193 closed enhancement (fixed)

Tests: Expand hook priority call order tests

Reported by: hellofromtonya's profile hellofromTonya Owned by: hellofromtonya's profile hellofromTonya
Milestone: 6.5 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-unit-tests commit
Focuses: Cc:

Description

#30875 identified more tests are needed to further test the call order for various priority data types.

Though add_action() and add_filter() priority are documented as int, there is no enforcement to require only an integer data type. It's highly likely numeric strings are being passed.

What happens if non-numeric data types and types are passed? These would represent the unhappy path datasets.

This ticket proposes adding both happy and unhappy datasets to further document what should happen for the call order when given the priority of different data types and values.

Change History (4)

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


4 months ago
#1

  • Keywords has-patch has-unit-tests added; needs-unit-tests removed

Expand the existing tests for hooks priority tests to futher check the call order for happy (numeric priorities) and unhappy (non-numeric priorities) paths.

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

#2 @hellofromTonya
3 months ago

  • Keywords commit added

Patch: https://github.com/WordPress/wordpress-develop/pull/5841

The patch is ready for commit.

It adds happy and unhappy path priority callback order tests for:

  • do_action()
  • WP_Hook::do_action()
  • apply_filters()
  • WP_Hook::apply_filters()

Though these tests may seem redundant, each of these functions have differing code that may impact the results. Thus testing each ensures the expected results and can help to protect against future regressions.

#3 @hellofromTonya
3 months ago

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

In 57257:

Tests: Add hook priority call order tests.

Adds happy (integer) and unhappy (non-integer) tests for validating the priority call order for:

  • do_action()
  • WP_Hook::do_action()
  • apply_filters()
  • WP_Hook::apply_filters()

As each of these functions have differing code, the tests are added to each to ensure expected results and protect against future regressions.

Follow-up to [53804], [52010], [25002], [25/tests], [62/tests].

Props hellofromTonya, mukesh27, dd32, valendesigns, drrobotnik.
Fixes #60193.

Note: See TracTickets for help on using tickets.