Skip to content

Tests: Cover wp_meta() - #15313

Closed
devmuhib009 wants to merge 1 commit into
WordPress:trunkfrom
devmuhib009:tests/65819-cover-wp-meta
Closed

devmuhib009 wants to merge 1 commit into
WordPress:trunkfrom
devmuhib009:tests/65819-cover-wp-meta

Conversation

@devmuhib009

Copy link
Copy Markdown
Member

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

What

Adds unit test coverage for the wp_meta() template function in tests/phpunit/tests/general/wpMeta.php.

Why

wp_meta() is a standard sidebar template tag that triggers the wp_meta action hook, allowing plugins to insert sidebar elements. It lacked direct unit test coverage and a dedicated @covers tag.

How

  • Verify that wp_meta() triggers the wp_meta action hook.
  • Verify that content echoed by hooked callbacks is output as expected using expectOutputString().

Testing Instructions

Run the test suite and coding standards check:

vendor/bin/phpunit --filter Tests_General_WpMeta
vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter Tests_General_WpMeta
vendor/bin/phpcs tests/phpunit/tests/general/wpMeta.php

All tests pass cleanly.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props devmuhib.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues with the added unit test coverage for wp_meta().

No open issues 🎉

What changed in this PR

Adds direct unit test coverage for the wp_meta() template function, addressing Trac ticket #65819 without changing production behavior.

Changes:

  • Verifies that wp_meta() fires its action hook exactly once.
  • Checks that content echoed by a hooked callback is output as expected.
  • Adds a dedicated @covers ::wp_meta annotation.
File Description
tests/​phpunit/​tests/​general/​wpMeta.php Adds a test covering action invocation and callback output for wp_meta().

Review effort: Balanced

@huzaifaalmesbah huzaifaalmesbah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Nice coverage for wp_meta(). LGTM.

AI Review: Opus 5.5

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please omit this standalone wrapper test. wp_meta() only calls do_action( 'wp_meta' ); the new mock count and callback output repeat hook dispatch behavior already exercised by Tests_Actions::test_simple_action() and the action callback tests. There is no additional formatting or branching in this wrapper. Direct coverage of this one-line delegate does not justify another fixture-backed test; no replacement test is requested.

AI review · gpt-6

@lancewillett

Copy link
Copy Markdown
Member

Thanks for contributing this. Closing this PR because wp_meta() only dispatches its hook; the action framework already has stronger dispatch coverage. The added callback output does not exercise behavior owned by this wrapper. Removing that standalone check leaves no useful remaining change, so no replacement test is needed.

AI review · gpt-6

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.

4 participants