Skip to content

Tests: Add unit coverage for get_wp_title_rss() - #15370

Closed
shail-mehta wants to merge 3 commits into
WordPress:trunkfrom
shail-mehta:tests/65819-cover-get-wp-title-rss
Closed

shail-mehta wants to merge 3 commits into
WordPress:trunkfrom
shail-mehta:tests/65819-cover-get-wp-title-rss

Conversation

@shail-mehta

@shail-mehta shail-mehta commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Trac ticket: #66474

What

Adds a dedicated PHPUnit class for get_wp_title_rss(), covering the get_wp_title_rss filter arguments with a fixed document title.

Test-only; no production code changes.

Why

get_wp_title_rss() had no direct @covers coverage. Document title composition is already covered by wp_get_document_title() tests; this keeps the feed-title filter contract.

How

Add tests/phpunit/tests/feed/getWpTitleRss.php with @covers ::get_wp_title_rss, using pre_get_document_title for a stable title and asserting filter call count and arguments.

Testing Instructions

docker compose up -d mysql
docker compose run --rm php ./vendor/bin/phpunit --filter Tests_Feed_GetWpTitleRss

Expected: OK (1 test, 3 assertions).

Use of AI Tools

  • Cursor

Cover the get_wp_title_rss filter arguments with a fixed document title.

See #65819.

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 identified for the test-only addition covering the get_wp_title_rss() filter contract.

No open issues 🎉

What changed in this PR

Adds direct PHPUnit coverage for get_wp_title_rss(), checking its filter contract without duplicating document-title composition tests. No production code changes.

Changes:

  • Adds a dedicated test class with @covers ::get_wp_title_rss.
  • Uses a fixed document title and verifies the filtered result, filter call count, and both filter arguments.
File Description
tests/​phpunit/​tests/​feed/​getWpTitleRss.php Adds a test for the feed-title filter’s arguments and returned value.

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review November 2, 2026 16:47
@github-actions

github-actions Bot commented Nov 2, 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 shailu25, lancewillett.

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.

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

The filtered-title result assertion protects useful behavior. Please keep that assertion and simplify the test by replacing the MockAction with a small callback, removing the call-count and default deprecated-argument assertions. The changed output already proves the filter ran; the unused default argument adds no demonstrated consumer protection here.

One method and one literal output assertion are enough. Targeted single-site/multisite runs and PHPCS pass.

AI review · gpt-6

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.

🟡 Changes recommended

The test leaves the filter-argument contract unprotected because its callback accepts only the title and cannot detect a missing or changed second argument.

1 open issue

Review effort: Balanced

Comment on lines +22 to +29
add_filter(
'get_wp_title_rss',
static function ( $title ) {
return $title . ' Custom';
}
);

$this->assertSame( 'Feed Title Custom', get_wp_title_rss() );

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

Approved at c513488. The test now checks the customized title, as requested. Mutation check: discarding the filter result is caught. On Copilot's thread: the deprecated argument and call count were dropped on purpose in the earlier review, so no change is needed.

1 test, 1 assertion in random order, single site and multisite. PHPCS clean. CI green.

AI review · claude-opus-5-5

@lancewillett

Copy link
Copy Markdown
Member

Thanks, @shail-mehta. Per #65819 comment 1521, test-only changes now get their own Trac ticket in the component of the code under test, instead of #65819. That now includes open PRs like this one.

Could you open a new ticket for this change (likely Feeds)? Please add the has-patch and has-unit-tests keywords, and update the Trac link in this PR's description. My approval stands. Once the description links the new ticket, this is ready to land.

AI review · claude-opus-5-5

@shail-mehta

Copy link
Copy Markdown
Member Author

Created Ticket: #66474

wporg-sync pushed a commit that referenced this pull request Nov 4, 2026
Add a test that a callback on the `get_wp_title_rss` filter receives the document title and can change the feed title that `get_wp_title_rss()` returns.

Developed in: #15370

Props shailu25.
Fixes #66474.


git-svn-id: https://develop.svn.wordpress.org/trunk@65257 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 65257
GitHub commit: 4e4783f

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Nov 4, 2026
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 4, 2026
Add a test that a callback on the `get_wp_title_rss` filter receives the document title and can change the feed title that `get_wp_title_rss()` returns.

Developed in: WordPress/wordpress-develop#15370

Props shailu25.
Fixes #66474.

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


git-svn-id: http://core.svn.wordpress.org/trunk@64406 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@github-project-automation github-project-automation Bot moved this from In review to Done in WordPress Project Build Tooling Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants