Skip to content

Tests: Assert comment list output in Recent Comments widget XHTML navigation test - #14338

Closed
shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:65819-recent-comments-xhtml-nav-assertion
Closed

shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:65819-recent-comments-xhtml-nav-assertion

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

What

Trac Ticket: #65819

Adds an assertion in Tests_Widgets_wpWidgetRecentComments::test_widget_omits_navigation_wrapper_in_xhtml() verifying that the 5 recent comments are still rendered in the widget output when the navigation format is xhtml.

Follow-up to r64357 / #14273 feedback in comment:175.

Why

Previously, test_widget_omits_navigation_wrapper_in_xhtml() only checked $this->assertFalse( $processor->next_tag( 'NAV' ) ). Because that is a negative assertion, an empty string or broken widget output would also satisfy the check and pass the test without rendering the comment list.

How

Calls $this->assertCount( 5, $this->get_listed_authors( $output ), 'The comments should still be listed.' ) after the <nav> tag check, matching the existing pattern used in test_widget_omits_title_markup_for_empty_filtered_title() in the same test class.

This is a test-only change; no production code is modified.

Testing Instructions

  1. Run the tests on single site:
    npm run test:php -- --filter Tests_Widgets_wpWidgetRecentComments
  2. Run the tests on multisite:
    npm run test:php -- -c tests/phpunit/multisite.xml --filter Tests_Widgets_wpWidgetRecentComments
  3. Run the tests in random order:
    npm run test:php -- --filter Tests_Widgets_wpWidgetRecentComments --order-by=random
  4. Run PHPCS on the test file:
    ./vendor/bin/phpcs tests/phpunit/tests/widgets/wpWidgetRecentComments.php

Use of AI Tools

  • Cursor

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

The assertion matches the existing fixtures and test pattern, with no unresolved issues.

0 open findings

What changed in this PR

Strengthens the Recent Comments widget’s XHTML navigation test without changing production code.

Changes:

  • Adds an assertion that five comments remain rendered, preventing empty output from passing the existing negative navigation check.
File Description
tests/​phpunit/​tests/​widgets/​wpWidgetRecentComments.php Asserts the rendered comment count in the XHTML navigation test.

🧠 Review effort: Balanced


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

@shail-mehta
shail-mehta marked this pull request as ready for review October 16, 2026 10:08
@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 shailu25.

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

@lancewillett lancewillett moved this from Backlog to In review in WordPress Project Build Tooling Oct 16, 2026
wporg-sync pushed a commit that referenced this pull request Oct 16, 2026
Assert that the Recent Comments widget still renders five comments in XHTML mode, alongside the existing check that it omits the navigation wrapper. This prevents empty output from satisfying the negative assertion.

Developed in: #14338

Props shailu25.
See #65819.


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

Copy link
Copy Markdown
Member

wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 16, 2026
Assert that the Recent Comments widget still renders five comments in XHTML mode, alongside the existing check that it omits the navigation wrapper. This prevents empty output from satisfying the negative assertion.

Developed in: WordPress/wordpress-develop#14338

Props shailu25.
See #65819.

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


git-svn-id: http://core.svn.wordpress.org/trunk@63568 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@shail-mehta
shail-mehta deleted the 65819-recent-comments-xhtml-nav-assertion branch October 21, 2026 09:06
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