Skip to content

Tests: Cover the_archive_title() - #15315

Closed
devmuhib009 wants to merge 1 commit into
WordPress:trunkfrom
devmuhib009:tests/65819-cover-the-archive-title
Closed

devmuhib009 wants to merge 1 commit into
WordPress:trunkfrom
devmuhib009:tests/65819-cover-the-archive-title

Conversation

@devmuhib009

Copy link
Copy Markdown
Member

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

What

Adds unit test coverage for the the_archive_title() template tag in tests/phpunit/tests/general/theArchiveTitle.php.

Why

While get_the_archive_title() has test coverage in tests/phpunit/tests/general/template.php, the display wrapper the_archive_title() lacked direct unit test coverage and a dedicated @covers tag.

How

  • Verify that the_archive_title() outputs the formatted archive title on an archive query.
  • Verify that before and after markup parameters are applied around the title.
  • Verify output when the prefix is filtered to an empty string.
  • Verify that the_archive_title() produces no output when the title is empty.

Testing Instructions

Run the test suite and coding standards check:

vendor/bin/phpunit --filter Tests_General_TheArchiveTitle
vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter Tests_General_TheArchiveTitle
vendor/bin/phpcs tests/phpunit/tests/general/theArchiveTitle.php

All tests pass cleanly.

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

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.

🟢 Approval recommended

No active review issues are identified for the added archive-title display tests.

No open issues 🎉

What changed in this PR

Adds direct unit test coverage for WordPress’s the_archive_title() display wrapper, complementing existing coverage for get_the_archive_title().

Changes:

  • Adds a dedicated test class with an explicit @covers annotation.
  • Verifies category archive output, before/after markup, and output with an empty prefix.
  • Confirms that an empty title produces no output, including no surrounding markup.
File Description
tests/​phpunit/​tests/​general/​theArchiveTitle.php Adds four tests covering archive title display and empty-output behavior.

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_the_archive_title_without_prefix() {

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: this one exercises get_the_archive_title() more than the wrapper, which has no prefix logic of its own, and template.php already uses the same filter. Feel free to drop it.

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

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

wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 1, 2026
Cover body-opening output, post type descriptions, archive descriptions and titles, and post type archive titles. Verify relevant display filters and return behavior.

Developed in: WordPress/wordpress-develop#15240, WordPress/wordpress-develop#15241, WordPress/wordpress-develop#15242, WordPress/wordpress-develop#15315, WordPress/wordpress-develop#15319

Props devmuhib, huzaifaalmesbah.
See #65819.

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


git-svn-id: http://core.svn.wordpress.org/trunk@64320 1a063a9b-81f0-0310-95a4-ce76da25c4cd
hubot pushed a commit to nacin/wp-develop that referenced this pull request Nov 1, 2026
Cover body-opening output, post type descriptions, archive descriptions and titles, and post type archive titles. Verify relevant display filters and return behavior.

Developed in: WordPress/wordpress-develop#15240, WordPress/wordpress-develop#15241, WordPress/wordpress-develop#15242, WordPress/wordpress-develop#15315, WordPress/wordpress-develop#15319

Props devmuhib, huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@65171 602fd350-edb4-49c9-b593-d223f7449a82
@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

None yet

Development

Successfully merging this pull request may close these issues.

4 participants