Tests: Add unit tests for wp_doing_sitemap() and the DOING_SITEMAP constant#3
Merged
masteradhoc merged 1 commit intoJun 21, 2026
Conversation
…nstant. Adds coverage for the wp_doing_sitemap() function introduced for #56954, including the default false result, the DOING_SITEMAP constant path, and the wp_doing_sitemap filter overriding both the default and the constant. Also adds integration tests asserting that WP_Sitemaps::render_sitemaps() defines the DOING_SITEMAP constant while rendering a sitemap, and that the constant is not defined when sitemaps are disabled. See #56954.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the unit test coverage requested in review on WordPress#12150 for the
DOING_SITEMAPconstant andwp_doing_sitemap()function.wp_doing_sitemap()(tests/phpunit/tests/load/wpDoingSitemap.php)falseon a regular request.wp_doing_sitemapfilter can force atrueresult.truewhen theDOING_SITEMAPconstant is defined.wp_doing_sitemapfilter can override the constant (returnsfalseeven whenDOING_SITEMAPistrue).WP_Sitemaps::render_sitemaps()(tests/phpunit/tests/sitemaps/sitemaps.php)DOING_SITEMAP(andwp_doing_sitemap()returnstrue) while rendering a sitemap.DOING_SITEMAPwhen sitemaps are disabled, confirming the constant is only set after the preliminary checks pass.Tests that depend on defining the constant run in a separate process so the constant does not leak across tests.
All new tests pass, and the full
Tests_Sitemaps_Sitemapssuite (21 tests) remains green.phpcspasses against theWordPress-Coreruleset.Trac ticket: https://core.trac.wordpress.org/ticket/56954