Skip to content

Tests: Add unit tests for the server-side rendering of the Query Pagination Numbers block - #15759

Closed
hmbashar wants to merge 1 commit into
WordPress:trunkfrom
hmbashar:test-query-pagination-numbers
Closed

hmbashar wants to merge 1 commit into
WordPress:trunkfrom
hmbashar:test-query-pagination-numbers

Conversation

@hmbashar

@hmbashar hmbashar commented Nov 6, 2026

Copy link
Copy Markdown

Summary

Adds tests for render_block_core_query_pagination_numbers() and register_block_core_query_pagination_numbers(), which had no tests.

  • The numbers of the first page and of the other pages (the cst argument that keeps the link of the first page), and no links to the previous and next page.
  • The page key with and without a query ID, and a page that is not a number.
  • The paged argument of the request that is kept in the links.
  • No output for one page or none, and the limit of the pages of the query.
  • The number of links around the current page (midSize), for a custom query and for a query that inherits the query of the page.
  • The attributes of the enhanced pagination (a key for each item, the click only on the links), and their absence without it.
  • A query that inherits the query of the page, and the main query that is restored after a custom query.
  • The registration of the block with its render callback (the original block type is put back afterwards).

Testing

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

Mutation check: 34 changes to the render function (the page key, the defaults, the limit, midSize in both branches, the format, the current page, the cst and paged arguments, the restore of the main query, the empty output, the attributes of the enhanced pagination and the wrapper) were each caught by a test.

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

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.

@github-actions

github-actions Bot commented Nov 6, 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