Repository navigation
Conversation
…ation Link block. See #66547.
|
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
When the block is already registered, the test fails to restore its original instance, leaving subsequent tests with a replacement that lacks bootstrapped support attributes.
1 open issue
What changed in this PR
Adds PHPUnit coverage for the Post Navigation Link block’s server-side rendering, support styles, and registration without changing production code.
Changes:
- Tests navigation links, labels, titles, arrows, taxonomy restrictions, and empty output.
- Verifies wrapper classes and styles, including borders, backgrounds, dimensions, shadows, and spacing.
- Checks that the block is registered with the expected render callback.
| File | Description |
|---|---|
tests/phpunit/tests/blocks/renderPostNavigationLink.php |
Adds fixtures and 48 test cases covering rendering, support styles, and registration. |
Review effort: Balanced
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 Navigation Link block (render_block_core_post_navigation_link(), block_core_post_navigation_link_get_support_styles(), and block registration). Local PHPUnit suite (48 tests, 52 assertions) and PHPCS/ESLint both pass cleanly.
I left a few small notes inline.
AI Review: Gemini 3.8 Flash
… cases. See #66547.
…link test. See #66547.

Adds unit tests for
render_block_core_post_navigation_link(),block_core_post_navigation_link_get_support_styles()andregister_block_core_post_navigation_link()insrc/wp-includes/blocks/post-navigation-link.php, which were not referenced by any test. No behavior is changed.The new test class
tests/phpunit/tests/blocks/renderPostNavigationLink.php(48 tests) covers:nextorprevious. The default is the next post.reland its label (NextorPrevious), or the label of the block (cleaned withwp_kses_post()).Next:orPrevious:).noneor an arrow that is not known.null, without the styles.block_core_post_navigation_link_get_support_styles(): the border (a number is converted to pixels, the style, the color and the sides), the background image with its size and position defaults, the gradient, the minimum dimensions, the shadow and the spacing.The function reads
$attributes['linkLabel']without checking that it is set (the block provides a default), so the tests pass it.Testing:
vendor/bin/phpunit --filter 'Tests_Blocks_RenderPostNavigationLink::'vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Tests_Blocks_RenderPostNavigationLink::'vendor/bin/phpcs tests/phpunit/tests/blocks/renderPostNavigationLink.phpI also temporarily broke the functions in about 45 ways (each check, the labels and the arrows, the link function and the taxonomy, the cast of the content, each style of the support and its defaults, and the registration) and confirmed that a new test fails for each one, except for two mutants that do not change the result: the strict comparison of
in_array()(a value of another type never matches the names of the types in PHP 8) and the check thathas-backgroundis not added twice (the style engine does not add it to the classes in those cases).Trac ticket: https://core.trac.wordpress.org/ticket/66547
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.