Repository navigation
Conversation
…mage 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.
🟢 Approval recommended
No active review issues remain for the added Post Featured Image helper tests.
No open issues 🎉
What changed in this PR
Adds unit tests for the Post Featured Image block’s border and overlay helpers, addressing the helper-testing portion of ticket #66546 without changing production behavior. Render callback coverage remains in a separate pull request.
Changes:
- Adds 21 test cases covering border attributes, color precedence, overlay classes and styles, and class escaping.
- Verifies that missing, zero, or null dim ratios produce no overlay.
- Saves and restores block-support state to isolate the tests.
| File | Description |
|---|---|
tests/phpunit/tests/blocks/postFeaturedImageHelpers.php |
Adds coverage for border attributes and overlay markup helpers. |
Review effort: Balanced
Adds unit tests for the helper functions of
src/wp-includes/blocks/post-featured-image.php,get_block_core_post_featured_image_border_attributes()andget_block_core_post_featured_image_overlay_element_markup(), which were not referenced by any test. No behavior is changed. This is the first part of the ticket: the render callback is covered in a separate pull request.The new test class
tests/phpunit/tests/blocks/postFeaturedImageHelpers.php(21 tests) covers:has-border-color), a named color (which takes precedence over a custom one), the style of a side, and nothing for other styles.has-background-gradient), a custom gradient, everything together with the border styles, the border classes, and the escaping of the classes.Testing:
vendor/bin/phpunit --filter 'Tests_Blocks_PostFeaturedImageHelpers::'vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Tests_Blocks_PostFeaturedImageHelpers::'vendor/bin/phpcs tests/phpunit/tests/blocks/postFeaturedImageHelpers.phpI also temporarily broke the functions (each part of the border, the precedence of the colors, each side, the classes and the styles that are returned, the check of the dim ratio, each class and style of the overlay and the escaping) 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.