Repository navigation
Conversation
…nts Form block. See #66541.
|
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:
|
huzaifaalmesbah
left a comment
There was a problem hiding this comment.
Thanks for working on this, @hmbashar! I really appreciate you taking the time to cover the server-side rendering of the Post Comments Form block (render_block_core_post_comments_form(), post_comments_form_block_form_defaults(), and block registration). Local PHPUnit suite (15 tests, 24 assertions) and PHPCS/ESLint both pass cleanly.
I left a couple of small notes inline.
AI Review: Gemini 3.8 Flash
There was a problem hiding this comment.
🟡 Changes recommended
The tests leak script and block-registry state into subsequent tests, and an integration assertion cannot detect a missing defaults-filter hookup.
3 open issues
What changed in this PR
Adds unit coverage for server-side rendering of the Post Comments Form block and its helper functions, addressing Trac ticket #66541 without changing production behavior.
Changes:
- Tests rendering conditions, wrapper classes, and the associated post.
- Checks script enqueueing, filter cleanup, and classic- versus block-theme form defaults.
- Verifies block registration and its render callback.
| File | Description |
|---|---|
tests/phpunit/tests/blocks/renderPostCommentsForm.php |
Adds tests for rendering, form defaults, side effects, and block registration. |
Review effort: Balanced
…rt the submit button in the post comments form tests. See #66541.


Adds unit tests for
render_block_core_post_comments_form(),post_comments_form_block_form_defaults()andregister_block_core_post_comments_form()insrc/wp-includes/blocks/post-comments-form.php, which were not referenced by any test. No behavior is changed.The new test class
tests/phpunit/tests/blocks/renderPostCommentsForm.php(15 tests) covers:postIdor when the comments are closed, and the function returnsnullfor a post that needs a password.id="respond"andcomment-respond), with thehas-text-align-*andhas-link-colorclasses of the block.comment-replyis enqueued only when the form is rendered, and the filter of the defaults of the form is removed afterwards.post_comments_form_block_form_defaults()leaves the defaults as they are for a theme that is not a block theme, and changes the submit button and the submit field for a block theme (also in the rendered form).Testing:
vendor/bin/phpunit --filter 'Tests_Blocks_RenderPostCommentsForm::'vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Tests_Blocks_RenderPostCommentsForm::'vendor/bin/phpcs tests/phpunit/tests/blocks/renderPostCommentsForm.phpI also temporarily broke the functions (each check, the classes, the filter that is removed, the post of the form, the replacement of the wrapper, the script, the check of the block theme, and the markup of the button and the field) and confirmed that a new test fails for each one. The
add_filter()call of the defaults is not caught, becausecomment_form()already applies the same defaults for a block theme.Trac ticket: https://core.trac.wordpress.org/ticket/66541
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.