Skip to content

Tests: Add unit tests for the helper functions of the Breadcrumbs block - #15784

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

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

Conversation

@hmbashar

@hmbashar hmbashar commented Nov 7, 2026

Copy link
Copy Markdown

Summary

Adds tests for the helper functions of the Breadcrumbs block, which had no tests. This is the first pull request for the ticket. The breadcrumbs of the archives, of the terms of a post and the block itself follow in separate pull requests.

  • block_core_breadcrumbs_is_paged(): the page numbers from which a view is paginated.
  • block_core_breadcrumbs_create_page_number_item(): the "Page N" and "Comments Page N" labels, the query variable that is read, and the formatting of the number.
  • block_core_breadcrumbs_create_item(): the current page item, and the link to the first page when paginated.
  • block_core_breadcrumbs_get_post_title(): the title (also as an object, filtered, and "0"), and the fallback for a post without a title.
  • block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs(): the ancestors from the top to the parent, none, and the fallback title.
  • block_core_breadcrumbs_get_term_ancestors_items(): the ancestors of a term from the top, none, and a taxonomy that is not hierarchical.

Testing

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

Mutation check: 23 changes to the functions were each caught by a test, except the is_taxonomy_hierarchical() check of the term ancestors, which does not change the output: get_ancestors() gives no ancestors for a taxonomy that is not hierarchical anyway.

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 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