Repository navigation
Conversation
…block. See #66543.
|
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: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the added Post Date rendering and registration tests.
No open issues 🎉
What changed in this PR
Adds unit tests for the Post Date block’s server-side rendering and registration, addressing the Post Date portion of Trac #66543 without changing production behavior.
Changes:
- Covers publish and modified dates, binding fallback, empty dates, formatting, and relative dates.
- Checks escaping, post links, and attribute-driven CSS classes.
- Verifies registration with the expected render callback.
| File | Description |
|---|---|
tests/phpunit/tests/blocks/renderPostDate.php |
Adds 26 test cases covering Post Date rendering and block registration. |
Review effort: Balanced
Adds unit tests for
render_block_core_post_date()andregister_block_core_post_date()insrc/wp-includes/blocks/post-date.php, which were not referenced by any test. No behavior is changed. This is the first part of the ticket: the Post Excerpt block is covered in a separate pull request.The new test class
tests/phpunit/tests/blocks/renderPostDate.php(26 tests) covers:core/post-data), the modified date fordisplayTypemodified(with thewp-block-post-date__modified-dateclass), and thedatetimeattribute when it is set. A binding that is complete does not replace it, and an incomplete one does not stop the date of the post from being used.datetime.... ago) and of a future date (... from now), and the formatted date and thedatetimeattribute are escaped.isLinklinks the date to the post (with an escaped URL), and not without a post or when it is false.has-text-align-*,has-link-color, both together, and none for another element.Testing:
vendor/bin/phpunit --filter 'Tests_Blocks_RenderPostDate::'vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Tests_Blocks_RenderPostDate::'vendor/bin/phpcs tests/phpunit/tests/blocks/renderPostDate.phpI also temporarily broke the function (each part of the check of the bindings, the field and the class of the modified date, the empty check, the format and its default, the time difference and its texts, the escaping, the link and the classes) and confirmed that a new test fails for each one.
Trac ticket: https://core.trac.wordpress.org/ticket/66543
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Written with AI and manually reviewed by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.