Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#60193 closed enhancement (fixed)

Tests: Expand hook priority call order tests

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

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.


3 years 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 years 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 years ago

  • Resolution → fixed
  • Status assigned → 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.