Skip to content

Tests: Stop the no-theme-support title test from removing support - #13861

Open
lancewillett wants to merge 1 commit into
WordPress:trunkfrom
lancewillett:fix/65893-title-tag-support
Open

lancewillett wants to merge 1 commit into
WordPress:trunkfrom
lancewillett:fix/65893-title-tag-support

Conversation

@lancewillett

@lancewillett lancewillett commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Trac ticket: core.trac.wordpress.org/ticket/65893

Tests_General_wpGetDocumentTitle::test__wp_render_title_no_theme_support() calls remove_theme_support( 'title-tag' ), and nothing restores it. Any time test__wp_render_title_tag() or test__wp_render_title_tag_with_blog_description() runs after it, those two fail. The class's after_setup_theme callback never fires during a test, and adding the support back after wp_loaded triggers a doing-it-wrong notice.

The test now filters current_theme_supports-title-tag to return false. _wp_render_title_tag() only checks current_theme_supports(), so the no-support path is still covered, and the base test case removes the filter after the test.

Testing Instructions

  1. Start the environment: npm run env:start && npm run env:install.
  2. Run npm run test:php -- --filter Tests_General_wpGetDocumentTitle --order-by=reverse. On trunk: 19 tests, 2 failures. On this branch: 19 tests pass.
  3. Run npm run test:php -- --test-suffix .php tests/phpunit/tests/general --order-by=random --random-order-seed=3. On trunk: 1 failure (test__wp_render_title_tag). On this branch: 318 tests pass. Default order and seeds 1 and 2 also pass.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code, Codex
Model(s): Claude Opus 5.5, gpt-6-astra (Codex review)
Used for: reproducing the failure, making the change, running the tests, and a second-model review


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.

`Tests_General_wpGetDocumentTitle::test__wp_render_title_no_theme_support()` called `remove_theme_support( 'title-tag' )`, and nothing restored it, so `test__wp_render_title_tag()` and `test__wp_render_title_tag_with_blog_description()` failed whenever they ran after it. The class's `after_setup_theme` callback never fires during a test, and adding the support again after `wp_loaded` triggers a doing-it-wrong notice.

The test now filters `current_theme_supports-title-tag` to return false, which the base test case removes after each test.

See #65893.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

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. You can also manually ask me to refresh this list by adding the props-bot label.

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

Props lancewillett.

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

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.

Copilot review overview

🟢 Approval recommended

The filter exercises the intended branch and is automatically restored during test teardown.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents document-title tests from leaking theme-support state across tests.

Changes:

  • Uses a temporary filter to simulate missing title-tag support without mutating global theme support.
File Description
tests/​phpunit/​tests/​general/​wpGetDocumentTitle.php Isolates the no-theme-support test.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants