Skip to content

Tests: Add unit test coverage for the_modified_time() - #14449

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

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

Conversation

@rejaulalomkhan

Copy link
Copy Markdown

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

Test scenarios covered:

  • Displaying post modified time in default format matching get_option( 'time_format' ).
  • Respecting various custom date/time formats (H:i:s, g:i a, Y-m-d H:i, l, H, i) via @dataProvider.
  • Respecting changes to the time_format option when no format argument is supplied.
  • Outputting nothing when no global $post exists.
  • The the_modified_time filter hook arguments verification (receives $get_the_modified_time and $format).
  • Customizing displayed output via the the_modified_time filter hook.
  • Respecting the underlying get_the_modified_time filter hook.

Verification:

  • Single-site PHPUnit: OK (12 tests, 15 assertions)
  • Multisite PHPUnit: OK (12 tests, 15 assertions)
  • Randomized order PHPUnit: OK (12 tests, 15 assertions)
  • Full date test group: OK (363 tests, 1286 assertions)
  • PHPCS (WordPress-Core): Clean (0 errors, 0 warnings)
  • Mutation testing: Verified 11 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 default modified time formatting, custom format strings via data provider, the time_format option, missing global post fallback, and the the_modified_time and get_the_modified_time filter hooks.

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

No open issues 🎉

What changed in this PR

Adds PHPUnit coverage for WordPress’s the_modified_time() template function without changing production code.

Changes:

  • Tests default and custom formats, option changes, and missing global posts.
  • Verifies filter arguments and filtered output.
File Description
tests/​phpunit/​tests/​date/​theModifiedTime.php Adds fixtures and tests for modified-time output and filters.

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 distinct creation and modification timestamps make the output checks meaningful. Optional cleanup: remove the computed-default expectation; the literal time-format option case already covers omitted-format behavior.

Unit-tests audit and Copilot review found no blockers. PHPCS passed all ten files. The combined batch passed locally in randomized order: single-site 149 tests / 283 assertions (seed 65825), multisite 140 tests / 236 assertions (seed 65826). 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 modification times, explicit and configured formats, missing posts, and display and retrieval filters. Use distinct creation and modification timestamps.

Developed in: #14449

Props rejaulalomkhan.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64543 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 modification times, explicit and configured formats, missing posts, and display and retrieval filters. Use distinct creation and modification timestamps.

Developed in: WordPress/wordpress-develop#14449

Props rejaulalomkhan.
See #65819.

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


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