Skip to content

Tests: expand hooks priority tests to further check call order for happy and unhappy paths#5841

Closed
hellofromtonya wants to merge 5 commits into
WordPress:trunkfrom
hellofromtonya:try/expand-hook-priority-testing
Closed

Tests: expand hooks priority tests to further check call order for happy and unhappy paths#5841
hellofromtonya wants to merge 5 commits into
WordPress:trunkfrom
hellofromtonya:try/expand-hook-priority-testing

Conversation

@hellofromtonya
Copy link
Copy Markdown
Contributor

@hellofromtonya hellofromtonya commented Jan 4, 2024

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

Call order tests added to:

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

The tests are redundant, yes, but necessary to test at least functional level, given there's different logic in each of these functions.

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


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@hellofromtonya hellofromtonya force-pushed the try/expand-hook-priority-testing branch 2 times, most recently from 0ea126e to 3e50d6b Compare January 4, 2024 20:37
Comment thread .env Outdated
Comment thread tests/phpunit/tests/actions.php Outdated
@hellofromtonya hellofromtonya force-pushed the try/expand-hook-priority-testing branch 2 times, most recently from f6fdb0c to fdae408 Compare January 8, 2024 19:13
Adds (2) dataProviders for each path.
Reworks the test to validate the call order for both.
@hellofromtonya hellofromtonya force-pushed the try/expand-hook-priority-testing branch from fdae408 to c491384 Compare January 8, 2024 19:29
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 8, 2024

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@hellofromtonya
Copy link
Copy Markdown
Contributor Author

@hellofromtonya hellofromtonya deleted the try/expand-hook-priority-testing branch January 9, 2024 18:03
@hellofromtonya hellofromtonya restored the try/expand-hook-priority-testing branch January 9, 2024 18:03
@hellofromtonya hellofromtonya deleted the try/expand-hook-priority-testing branch January 9, 2024 18:04
@spadagblog-spec
Copy link
Copy Markdown

Another alternative to #5811 and #5835. Uses some code from #5609.
Trac ticket: https://core.trac.wordpress.org/ticket/60193

Good idea, but it’s more of a workaround than a full solution.

  • Allowing parsed-style definitions (block + attrs) in hooked_block_types is a solid improvement—cleaner and more flexible than just strings.
  • Using core/pattern works for composition and layout, but it’s static and not context-aware, so it won’t handle dynamic layout needs.
  • The real gap is lack of context-aware hooked blocks (based on surrounding blocks).

Best direction:

  • Support attributes in hooked blocks (via filter, maybe block.json for simple cases)
  • Keep patterns for reusable layouts, not dynamic injection

Implements an idea originally conceived of in https://core.trac.wordpress.org/ticket/60193:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants