Repository navigation
Conversation
…red Image block. See #66546.
|
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.
🟡 Changes recommended
The test fails to restore the original block registration, leaving a replacement without bootstrap-added support attributes and altering the schema seen by subsequent tests.
1 open issue
What changed in this PR
Adds unit coverage for the Post Featured Image block’s server-side rendering and registration, supporting Trac ticket #66546 without changing production code.
Changes:
- Tests image selection, links and escaping, alternative text, styles, and overlays.
- Covers first-content-image fallback and featured-image precedence.
- Verifies registration of the render callback.
| File | Description |
|---|---|
tests/phpunit/tests/blocks/renderPostFeaturedImage.php |
Adds fixtures, helpers, and tests for rendering and block registration. |
Review effort: Balanced
…istration test. See #66546.

Adds unit tests for
render_block_core_post_featured_image()andregister_block_core_post_featured_image()insrc/wp-includes/blocks/post-featured-image.php, which were not referenced by any test. No behavior is changed. This is the second part of the ticket: the helper functions are covered in a separate pull request.The new test class
tests/phpunit/tests/blocks/renderPostFeaturedImage.php(33 tests) covers:<figure>with the size of the block (post-thumbnailby default), and the classes of the border on the image.isLinklinks the image to the post, with the target and the optional rel, and escaped URL, target and rel. The image is not linked forfalse,nullor zero. The alternative text of a linked image is the title of the post without tags, orUntitled post <ID>.auto), the height, the width (withheight:autowithout a height), the scale, the shadow, the border before them, and nothing for empty values.useFirstImageFromPost: the first image of the content is used when the post has no featured image (with its attributes, and the styles of the block added to its own), not before the featured image, and nothing is rendered when there is no image.Testing:
vendor/bin/phpunit --filter 'Tests_Blocks_RenderPostFeaturedImage::'vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Tests_Blocks_RenderPostFeaturedImage::'vendor/bin/phpcs tests/phpunit/tests/blocks/renderPostFeaturedImage.phpI also temporarily broke the function in about 35 ways (each check, the link and its attributes and escaping, the alternative text, each part of the styles, the first image and the merge of the styles, the overlay and the render callback) and confirmed that a new test fails for each one.
Trac ticket: https://core.trac.wordpress.org/ticket/66546
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.