Skip to content

Tests: Cover get_the_generator(), the_generator(), and wp_generator() - #15324

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

devmuhib009 wants to merge 1 commit into
WordPress:trunkfrom
devmuhib009:tests/65819-cover-the-generator

Conversation

@devmuhib009

Copy link
Copy Markdown
Member

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

This PR adds unit tests for get_the_generator(), the_generator(), and wp_generator() covering:

  • Output formats across supported generator types (html, xhtml, atom, rss2, rdf, comment, export)
  • Returning null when type is empty and no action context is active
  • get_the_generator_$type filter hook
  • the_generator() echo display with a trailing newline
  • the_generator display filter hook
  • wp_generator() default XHTML generator display and wp_generator_type filter hook

@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

No active review issues are reported for the test-only change adding PHPUnit coverage of WordPress generator markup functions.

No open issues 🎉

What changed in this PR

Adds PHPUnit coverage for WordPress’s generator markup functions, supporting Trac ticket #65819. No production code changes are included.

Changes:

  • Tests all supported generator formats, including timestamped export markup.
  • Verifies null returns when the type is empty and no action context is active.
  • Covers generator filters, echoed output with a trailing newline, and wp_generator()’s default XHTML format.
File Description
tests/​phpunit/​tests/​general/​getTheGenerator.php Adds tests for get_the_generator(), the_generator(), and wp_generator().

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.

I left a few small notes inline.

AI Review: Opus 5.5

*
* @ticket 65819
*/
public function test_get_the_generator_returns_null_when_type_empty() {

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.

This one looks like a small coverage gap: with an empty $type, only the null return is reached. The current_filter() switch that picks the type (rss2_head, rss_head, rdf_header, atom_head and so on) has no test, and changing its mappings failed nothing locally. Could you add a provider that pushes each hook onto $wp_current_filter, inside try/finally, and checks the markup?

* @param string $expected Expected markup template with placeholder for version.
*/
public function test_get_the_generator_types( $type, $expected ) {
$version = ( 'atom' === $type || 'rss2' === $type || 'rdf' === $type )

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.

Optional: get_bloginfo() and get_bloginfo_rss() are the calls the source makes, so the expected value partly mirrors it. Feel free to use wp_get_wp_version() for all types, which also removes this conditional.

@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.

Reviewed the changed code against the implementation and existing coverage; no blocking issue found.

Validated with the related behavioral coverage patches on current trunk: 35 tests / 43 assertions in each of single-site and multisite, randomized seed 1101. No failures, errors, warnings, or skips.

Current-head CI and Copilot review checked.

AI review · gpt-6

wporg-sync pushed a commit that referenced this pull request Nov 1, 2026
Verify `get_the_generator()` output formats and filtering, and the display behavior of `the_generator()` and `wp_generator()`.

Developed in: #15324

Props devmuhib, huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@65172 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 1, 2026
Verify `get_the_generator()` output formats and filtering, and the display behavior of `the_generator()` and `wp_generator()`.

Developed in: WordPress/wordpress-develop#15324

Props devmuhib, huzaifaalmesbah.
See #65819.

Built from https://develop.svn.wordpress.org/trunk@65172


git-svn-id: http://core.svn.wordpress.org/trunk@64321 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@lancewillett

Copy link
Copy Markdown
Member

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