Repository navigation
Tests: Cover get_the_generator(), the_generator(), and wp_generator() - #15324
devmuhib009 wants to merge 1 commit into
Conversation
…. See #65819. Props devmuhib009.
|
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: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
There was a problem hiding this comment.
🟢 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
left a comment
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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 ) |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
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
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
|
PR #15324 landed in https://core.trac.wordpress.org/changeset/65172 |
Trac ticket: https://core.trac.wordpress.org/ticket/65819
This PR adds unit tests for
get_the_generator(),the_generator(), andwp_generator()covering:html,xhtml,atom,rss2,rdf,comment,export)nullwhen type is empty and no action context is activeget_the_generator_$typefilter hookthe_generator()echo display with a trailing newlinethe_generatordisplay filter hookwp_generator()default XHTML generator display andwp_generator_typefilter hook