Skip to content

Tests: Add unit test coverage for the_modified_author() - #14456

Closed
rejaulalomkhan wants to merge 1 commit into
WordPress:trunkfrom
rejaulalomkhan:tests/the-modified-author
Closed

rejaulalomkhan wants to merge 1 commit into
WordPress:trunkfrom
rejaulalomkhan:tests/the-modified-author

Conversation

@rejaulalomkhan

Copy link
Copy Markdown

Adds unit test coverage for the_modified_author() in src/wp-includes/author-template.php.

Test scenarios covered:

  • Displaying the display name of the editor who last edited the post via _edit_last.
  • Displaying the author's display name when the author is also the last editor.
  • Outputting nothing when the post has no _edit_last post meta.
  • Outputting nothing when _edit_last points to a non-existent or deleted user ID.
  • Outputting nothing when no global $post exists.
  • Modifying displayed output via the the_modified_author filter hook.
  • Respecting various custom display names (ASCII, Unicode, HTML entities, single words) via @dataProvider.

Verification:

  • Single-site PHPUnit: OK (10 tests, 10 assertions)
  • Multisite PHPUnit: OK (10 tests, 10 assertions)
  • Randomized order PHPUnit: OK (10 tests, 10 assertions)
  • Related getTheModifiedAuthor test suite: OK (5 tests, 9 assertions)
  • PHPCS (WordPress-Core): Clean (0 errors, 0 warnings)
  • Mutation testing: Verified 7 test failures when the echo statement is omitted.

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


Use of AI Tools: Antigravity (Gemini 2.5) was used to assist in test case ideation, code scaffolding, and formatting to WordPress core standards. All assertions and test outcomes were verified locally through PHPUnit and PHPCS.

Adds comprehensive PHPUnit tests covering display of the last editor's display name, author as last editor, missing _edit_last meta fallback, non-existent user fallback, missing global post fallback, the the_modified_author filter hook, and custom display names via data provider.

See #65819.
@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 rejaulalomkhan.

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

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 tests match existing behavior and test isolation mechanisms, with no blocking issues identified.

No open issues 🎉

What changed in this PR

Adds unit coverage for the_modified_author() without changing production behavior.

Changes:

  • Tests editor and author display names, missing metadata, nonexistent users, and absent global posts.
  • Verifies filter customization and varied display names.
File Description
tests/​phpunit/​tests/​user/​theModifiedAuthor.php Adds fixtures and output assertions for ten test cases.

Review effort: Balanced

@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 literal output checks distinguish the editor from the original author and cover filtered output and display names. Optional cleanup: trim wrapper cases already covered by get_the_modified_author() while retaining the exact-output and escaping-sensitive cases.

Unit-tests audit and Copilot review found no blockers. PHPCS passed. Each class passed separately, and the combined batch passed randomized single-site and multisite runs: 63 tests, 95 assertions each (seeds 65829 and 65830). CI is green on the reviewed commit.

AI review · gpt-6

wporg-sync pushed a commit that referenced this pull request Oct 19, 2026
Verify echoed editor names, missing editor or post context, display-name handling, and filtered output.

Developed in: #14456

Props rejaulalomkhan.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64548 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 19, 2026
Verify echoed editor names, missing editor or post context, display-name handling, and filtered output.

Developed in: WordPress/wordpress-develop#14456

Props rejaulalomkhan.
See #65819.

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


git-svn-id: http://core.svn.wordpress.org/trunk@63698 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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