Skip to content

Tests: Add unit coverage for comment_excerpt() - #15281

Open
shail-mehta wants to merge 3 commits into
WordPress:trunkfrom
shail-mehta:tests/comment-excerpt-65819
Open

shail-mehta wants to merge 3 commits into
WordPress:trunkfrom
shail-mehta:tests/comment-excerpt-65819

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

Trac ticket: #65819

What

Adds a dedicated PHPUnit class for comment_excerpt(), covering display output, comment objects, the global comment fallback, and the display filter.

Test-only; no production code changes.

Why

comment_excerpt() had no direct @covers coverage. Small helper coverage fits the #65819 test cleanup track.

How

Add tests/phpunit/tests/comment/commentExcerpt.php with @covers ::comment_excerpt and @covers ::get_comment_excerpt.

Testing Instructions

  1. npm run test:php -- --filter Tests_Comment_CommentExcerpt
  2. npm run test:php -- --filter Tests_Comment_CommentExcerpt -c tests/phpunit/multisite.xml
  3. npm run test:php -- --filter Tests_Comment_CommentExcerpt --order-by=random
  4. npm run test:php -- --group comment

Use of AI Tools

  • Cursor

Add unit tests for excerpt display output, comment objects, global fallback, and the display filter.

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 reported for this test-only addition of PHPUnit coverage for comment excerpt behavior.

No open issues 🎉

What changed in this PR

Adds dedicated PHPUnit coverage for comment_excerpt() as part of the #65819 test cleanup effort. This is a test-only change with no production code changes.

Changes:

  • Tests echoed output with a comment ID or comment object.
  • Covers the global comment fallback and display-filter customization.
  • Adds explicit coverage annotations for comment_excerpt() and get_comment_excerpt().
File Description
tests/​phpunit/​tests/​comment/​commentExcerpt.php Adds four tests covering excerpt output, accepted inputs, global fallback, and filtering.

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review October 31, 2026 17:26
@github-actions

github-actions Bot commented Oct 31, 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.

Please use the literal fixture text, Short comment excerpt text., as the expected output in the three unfiltered display tests. Calling get_comment_excerpt() to compute the expected result lets a regression in that same getter change both sides of the assertion. The fixture already tells us the intended output.

The tests pass locally in randomized single-site and multisite runs; this small change makes their oracle independent before landing.

AI review · gpt-6

Avoid deriving expectations from get_comment_excerpt() so the display assertions stay independent of that getter.

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 this test-only addition of direct PHPUnit coverage for comment_excerpt().

No open issues 🎉

Review effort: Balanced

@shail-mehta

Copy link
Copy Markdown
Member Author

Thanks for the review!

Addressed in 61e97c0

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.

3 participants