Skip to content

Tests: Add unit tests for the server-side rendering of the Navigation Submenu block - #15783

Closed
hmbashar wants to merge 1 commit into
WordPress:trunkfrom
hmbashar:test-navigation-submenu-render
Closed

hmbashar wants to merge 1 commit into
WordPress:trunkfrom
hmbashar:test-navigation-submenu-render

Conversation

@hmbashar

@hmbashar hmbashar commented Nov 7, 2026

Copy link
Copy Markdown

Summary

Adds tests for render_block_core_navigation_submenu(), the server-side rendering of the Navigation Submenu block, which had no tests. This is the second and last pull request for the ticket; the first one covers the helper functions.

  • Nothing is rendered without a label, or for a linked post that is not published (the allowed statuses can be filtered). Links to terms are not checked.
  • The item with its link: the URL, the target, the rel and nofollow attributes, the title, the label and the description, with their escaping and filtering.
  • The inner blocks in a submenu, and no submenu when the inner blocks have no output.
  • The classes of the submenu visibility (hover, click, always, and the deprecated openSubmenusOnClick) with and without submenu icons.
  • The button next to the link, and the button in place of the link when the submenu opens on click, with the escaped label.
  • The current page, the current term, the archive of the current post type, and the ancestor of the current page.
  • The overlay colors, the custom overlay colors and the shadow, which go to the submenu and not to the item.

The test restores the supports of the block type, which the render function changes. The branch of the function for the Gutenberg plugin is not tested.

Testing

vendor/bin/phpunit --filter 'Tests_Blocks_RenderNavigationSubmenu::'
vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Tests_Blocks_RenderNavigationSubmenu::'
vendor/bin/phpunit --group blocks
vendor/bin/phpcs tests/phpunit/tests/blocks/renderNavigationSubmenu.php

Mutation check: 52 changes to the function (every condition, class, attribute, escaping and color) were each caught by a test.

Trac ticket: https://core.trac.wordpress.org/ticket/66589

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.

@hmbashar
hmbashar marked this pull request as ready for review November 7, 2026 06:26
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

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:

Props hmbashar.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@hmbashar hmbashar closed this Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant