Skip to content

Tests: Add unit tests for the server-side rendering of the Breadcrumbs block - #15803

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

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

Conversation

@hmbashar

@hmbashar hmbashar commented Nov 7, 2026

Copy link
Copy Markdown

Summary

Adds tests for render_block_core_breadcrumbs(), the server-side rendering of the Breadcrumbs block, which had no tests. This is the fourth and last pull request for the ticket; the earlier ones cover the helper functions, the archives and the terms of a post.

  • The wrapper: the navigation, its label and the separator.
  • The home item: hidden on the front page unless it is set to be shown, a link away from the front page, left out when it is turned off, and the page number on a paginated front page of posts or static front page.
  • The page of the posts (also paginated), the search results (trimmed and escaped, also paginated), the page that is not found, and the archives.
  • A single post: nothing without the context or the post, the category, the archive link of the post type (also the page for posts), the ancestors of a page, the terms of a hierarchical post type when the taxonomy is preferred, and the trail of the parent for an attachment.
  • The title of the post (filtered, with a fallback), linked with the page number or the comments page number when paginated.
  • The current item can be left out, the block_core_breadcrumbs_items filter, and the escaping of the labels and the URLs.

Testing

vendor/bin/phpunit --filter 'Tests_Blocks_RenderBreadcrumbs::'
vendor/bin/phpunit -c tests/phpunit/multisite.xml --filter 'Tests_Blocks_RenderBreadcrumbs::'
vendor/bin/phpcs tests/phpunit/tests/blocks/renderBreadcrumbs.php

Mutation check: 56 changes to the function (every branch, condition, label, link and the escaping) were each caught by a test, except two that do not change the output: the check of an empty list before removing the current item (removing an item from an empty list changes nothing), and the escaping of backslashes and quotes of the separator (a separator with them gives a style that is removed on output either way).

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

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 07:48
@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