Skip to content

Tests: Cover bloginfo() - #15320

Closed
devmuhib009 wants to merge 3 commits into
WordPress:trunkfrom
devmuhib009:tests/65819-cover-bloginfo
Closed

devmuhib009 wants to merge 3 commits into
WordPress:trunkfrom
devmuhib009:tests/65819-cover-bloginfo

Conversation

@devmuhib009

Copy link
Copy Markdown
Member

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

This PR adds unit tests for bloginfo() covering:

  • Default site title display output
  • Explicit bloginfo( 'name' ) output
  • Site URL display output
  • Site description (tagline) display output
  • Filtering via the bloginfo 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, huzaifaalmesbah, 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.

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 tests assume fixed site titles and URLs without setting the corresponding options, causing false failures when WP_TESTS_TITLE or WP_TESTS_DOMAIN differs from the expected values.

2 open issues
What changed in this PR

Adds PHPUnit coverage for WordPress’s bloginfo() display behavior, supporting Trac ticket #65819.

Changes:

  • Tests default and explicit site-name output, the home URL, and the site description.
  • Verifies that the bloginfo filter can modify the displayed site title.
File Description
tests/​phpunit/​tests/​general/​bloginfo.php Adds five tests covering displayed site information and filtering.

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_bloginfo_url() {
$this->expectOutputString( 'http://example.org' );

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.

Copilot flagged this too, and it is what fails in the two example.org:8889 jobs, where the output is http://example.org:8889. Setting the option in the test keeps the literal value and works on both:

Suggested change
$this->expectOutputString( 'http://example.org' );
update_option( 'home', 'http://example.org' );
$this->expectOutputString( 'http://example.org' );

* @ticket 65819
*/
public function test_bloginfo_default_displays_name() {
$this->expectOutputString( 'Test Blog' );

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: as Copilot noted, 'Test Blog' comes from WP_TESTS_TITLE, here and in test_bloginfo_name(). Feel free to set blogname in these tests 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.

Please make the site title and home URL explicit fixtures before asserting their literal values. The new tests assume Test Blog and http://example.org, but those values come from configurable installation settings. In particular, a home URL containing :8889 is valid and cannot satisfy the current URL assertion. This confirms the existing inline feedback; no production change is needed.

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.

🟢 Approval recommended

No active review issues were identified in the added PHPUnit coverage for bloginfo() output and filtering.

No open issues 🎉

2 resolved since last review

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.

Thanks for the quick update, @devmuhib009! Setting explicit option fixtures (blogname, home, blogdescription) ensures deterministic assertions across all environments and addresses the review feedback cleanly. LGTM!

AI Review: Gemini 3.8 Flash

@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 explicit option fixtures fix the configuration-dependent failures. Please also trim two overlapping additions: remove test_bloginfo_name() and test_bloginfo_description().

Keep the default, URL, and filter cases: they protect the default selector, a non-name selector, and display-mode filtering. The explicit-name output repeats the default case, while existing Tests_Formatting_GetBloginfo checks name/description retrieval. No replacement tests are needed.

The affected classes pass randomized single-site and multisite runs (13 tests, 42 assertions each), and PHPCS passes. This remaining request is about avoiding duplicate coverage, not a failing assertion.

AI review · gpt-6

@devmuhib009

Copy link
Copy Markdown
Member Author

Updated! Removed the overlapping test_bloginfo_name() and test_bloginfo_description() test methods, keeping the focused default, URL, and filter cases as requested. Thank you @lancewillett for the review!

@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 99fe4b2. The redundant name and description cases are gone. test_bloginfo_url() now sets home itself, which fixes the example.org:8889 failure @huzaifaalmesbah raised, and the name thread no longer applies.

Exact head: 3 tests, 3 assertions in random order, single site and multisite. PHPCS clean. CI green.

AI review · claude-opus-5-5

wporg-sync pushed a commit that referenced this pull request Nov 3, 2026
Verify that `bloginfo()` prints the site name by default, prints the home URL for `url`, and prints the value returned by the `bloginfo` filter.

Developed in: #15320

Props devmuhib, huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@65233 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 3, 2026
Verify that `bloginfo()` prints the site name by default, prints the home URL for `url`, and prints the value returned by the `bloginfo` filter.

Developed in: WordPress/wordpress-develop#15320

Props devmuhib, huzaifaalmesbah.
See #65819.

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


git-svn-id: http://core.svn.wordpress.org/trunk@64382 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

Development

Successfully merging this pull request may close these issues.

4 participants