Skip to content

Tests: Cover the_posts_navigation() - #15321

Open
devmuhib009 wants to merge 2 commits into
WordPress:trunkfrom
devmuhib009:tests/65819-cover-the-posts-navigation
Open

devmuhib009 wants to merge 2 commits into
WordPress:trunkfrom
devmuhib009:tests/65819-cover-the-posts-navigation

Conversation

@devmuhib009

Copy link
Copy Markdown
Member

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

This PR extends Tests_Link_GetThePostsNavigation to cover the_posts_navigation() echoing the navigation markup with custom arguments.

@github-actions

github-actions Bot commented Nov 1, 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 devmuhib, huzaifaalmesbah, lancewillett.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The pagination test hard-codes example.org in expected links, causing false failures when WP_TESTS_DOMAIN differs; expected URLs should use home_url() and esc_url().

1 open issue
What changed in this PR

This PR extends WordPress’s posts-navigation tests to verify that the_posts_navigation() echoes markup with custom arguments.

Changes:

  • Adds an output assertion covering pagination links, a custom class, screen-reader text, and an ARIA label.
  • Updates the test class documentation and coverage annotations to include the_posts_navigation().
File Description
tests/​phpunit/​tests/​link/​getThePostsNavigation.php Adds the navigation echo test and updates coverage annotations.

Review effort: Balanced

}
);

$expected = '<nav class="echo-navigation" aria-label="Echo ARIA"><h2>Echo Reader</h2><div class="nav-previous"><a href="http://example.org/?paged=3" >Older posts</a></div><div class="nav-next"><a href="http://example.org/" >Newer posts</a></div></nav>';

@huzaifaalmesbah huzaifaalmesbah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few small notes inline.

AI Review: Opus 5.5

}
);

$expected = '<nav class="echo-navigation" aria-label="Echo ARIA"><h2>Echo Reader</h2><div class="nav-previous"><a href="http://example.org/?paged=3" >Older posts</a></div><div class="nav-next"><a href="http://example.org/" >Newer posts</a></div></nav>';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot flagged this too, and it is what fails in the two example.org:8889 jobs. home_url() works with both domains; I ran it locally with each:

Suggested change
$expected = '<nav class="echo-navigation" aria-label="Echo ARIA"><h2>Echo Reader</h2><div class="nav-previous"><a href="http://example.org/?paged=3" >Older posts</a></div><div class="nav-next"><a href="http://example.org/" >Newer posts</a></div></nav>';
$expected = '<nav class="echo-navigation" aria-label="Echo ARIA"><h2>Echo Reader</h2><div class="nav-previous"><a href="' . home_url( '/?paged=3' ) . '" >Older posts</a></div><div class="nav-next"><a href="' . home_url( '/' ) . '" >Newer posts</a></div></nav>';

*
* @ticket 65819
*
* @covers ::the_posts_navigation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: the class docblock already has @covers ::the_posts_navigation, and the other tests here don't repeat it. Feel free to drop this one.

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please derive the expected pagination URLs from the configured home URL and escape them as HTML URLs. The hard-coded http://example.org expectations reject a valid installation using another host or port. This confirms the existing inline feedback; the wrapper itself does not need changing.

AI review · gpt-6

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.

4 participants