Repository navigation
Conversation
…ate block. See #66544.
|
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 were identified in the added Post Template rendering and registration tests.
No open issues 🎉
What changed in this PR
Adds unit tests for the Post Template block’s server-side rendering and registration, addressing previously untested functions without changing production behavior.
Changes:
- Covers featured-image detection, query ordering and pagination, and inherited queries.
- Verifies rendered markup, layout classes, escaping, and enhanced-pagination keys.
- Checks block context, cleanup of filters and post data, and registration settings.
| File | Description |
|---|---|
tests/phpunit/tests/blocks/renderPostTemplate.php |
Adds 35 test cases covering Post Template rendering, helpers, and registration. |
Review effort: Balanced
Adds unit tests for
block_core_post_template_uses_featured_image(),render_block_core_post_template()andregister_block_core_post_template()insrc/wp-includes/blocks/post-template.php, which were not referenced by any test. No behavior is changed.The new test class
tests/phpunit/tests/blocks/renderPostTemplate.php(35 tests) covers:core/post-featured-imageblock, or acore/coverblock withuseFeaturedImage(not another block with that attribute), also when the block is nested.wp-block-postclasses of the post (escaped) is rendered for each post, with the inner blocks that get thepostIdandpostTypecontext.query-page, orquery-<id>-pagefor a query with an ID, and not the page of another query), and the main query when the block inherits it (with its own order and number).data-wp-keyof the items for the enhanced pagination.is-flex-containerand the columns), the link color, the grid (columns-Nandhas-native-responsive-grid), and none for other cases.core/null, the filter of the context is removed, and the post data is restored (a different post than the last one of the list is used to check it).skip_inner_blocks.Testing:
vendor/bin/phpunit --filter 'Tests_Blocks_RenderPostTemplate::'vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Tests_Blocks_RenderPostTemplate::'vendor/bin/phpcs tests/phpunit/tests/blocks/renderPostTemplate.phpI also temporarily broke the functions (the key of the page, the enhanced pagination, the page and the main query, the check of empty posts, each class of the list, the block name and the context of the items, the filter of the context, the classes and their escaping, the reset of the post data, the tag and the registration) and confirmed that a new test fails for each one.
Trac ticket: https://core.trac.wordpress.org/ticket/66544
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.