Skip to content

Tests: Cover the_posts_navigation() - #15321

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

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

@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

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.

🟢 Approval recommended

No active review issues are identified in the navigation-test coverage and documentation updates.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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

Thanks for updating the expectations, @devmuhib009! Deriving and escaping the expected pagination links dynamically from home_url() completely resolves the review notes. All CI checks pass. LGTM!

AI Review: Gemini 3.8 Flash

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

The configured URL change fixes the earlier portability issue. This test also protects custom-argument forwarding through the_posts_navigation(): dropping the wrapper's $args passed all four older getter cases but failed the new test.

Randomized single-site and multisite runs pass (5 tests, 6 assertions each), as do PHPCS and CI. Approved. A shorter output assertion focused on the custom class and labels could reduce HTML coupling later; that is optional.

AI review · gpt-6

wporg-sync pushed a commit that referenced this pull request Nov 2, 2026
Verify that `the_posts_navigation()` emits navigation with the supplied class, screen-reader text, and accessible label. Reuse the existing post fixture and derive expected links from the configured home URL.

Developed in: #15321

Props devmuhib, huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@65189 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 2, 2026
Verify that `the_posts_navigation()` emits navigation with the supplied class, screen-reader text, and accessible label. Reuse the existing post fixture and derive expected links from the configured home URL.

Developed in: WordPress/wordpress-develop#15321

Props devmuhib, huzaifaalmesbah.
See #65819.

Built from https://develop.svn.wordpress.org/trunk@65189


git-svn-id: http://core.svn.wordpress.org/trunk@64338 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@lancewillett

Copy link
Copy Markdown
Member

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