Repository navigation
Tests: Add unit test coverage for the_time() - #14447
rejaulalomkhan wants to merge 1 commit into
Conversation
Adds comprehensive PHPUnit tests covering default time formatting, custom format strings via data provider, the time_format option, missing global post fallback, and the the_time and get_the_time filter hooks. See #65819.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
🟢 Approval recommended
The focused tests match existing behavior and test isolation mechanisms, with no unresolved findings.
No open issues 🎉
What changed in this PR
Adds unit coverage for WordPress’s the_time() template function without changing production code.
Changes:
- Tests default, custom, and option-based time formats.
- Checks empty output when no global post exists.
- Verifies filter arguments and filtered output.
| File | Description |
|---|---|
| tests/phpunit/tests/date/theTime.php | Adds fixtures and tests for formatting, missing posts, and filters. |
Review effort: Balanced
lancewillett
left a comment
There was a problem hiding this comment.
The output, configured-format, and filter cases protect the display contract. 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
|
PR #14447 landed in https://core.trac.wordpress.org/changeset/64541 |
Verify echoed post times, explicit and configured formats, missing posts, and display and retrieval filters. Developed in: #14447 Props rejaulalomkhan. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64541 602fd350-edb4-49c9-b593-d223f7449a82
Verify echoed post times, explicit and configured formats, missing posts, and display and retrieval filters. Developed in: WordPress/wordpress-develop#14447 Props rejaulalomkhan. See #65819. Built from https://develop.svn.wordpress.org/trunk@64541 git-svn-id: http://core.svn.wordpress.org/trunk@63691 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds unit test coverage for
the_time()insrc/wp-includes/general-template.php.Test scenarios covered:
get_option( 'time_format' ).H:i:s,g:i a,Y-m-d H:i,l,H,i) via@dataProvider.time_formatoption when no format argument is supplied.$postexists.the_timefilter hook arguments verification (receives$get_the_timeand$format).the_timefilter hook.get_the_timefilter hook.Verification:
OK (12 tests, 15 assertions)OK (12 tests, 15 assertions)OK (12 tests, 15 assertions)OK (363 tests, 1286 assertions)0 errors, 0 warnings)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.