Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion tests/phpunit/tests/link/getThePostsNavigation.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

/**
* Tests the `get_the_posts_navigation()` function.
* Tests for get_the_posts_navigation() and the_posts_navigation().
*
* @since 6.2.0
*
* @group link
*
* @covers ::get_the_posts_navigation
* @covers ::the_posts_navigation
*/
class Tests_Link_GetThePostsNavigation extends WP_UnitTestCase {

Expand Down Expand Up @@ -104,4 +105,43 @@ public static function data_get_the_posts_navigation() {
),
);
}

/**
* Tests that the_posts_navigation() echoes the navigation markup.
*
* @ticket 65819
*/
public function test_the_posts_navigation_echoes() {
$this->set_permalink_structure( '' );
$this->go_to( home_url( '/' ) );

global $wp_query, $paged;

$paged = 2;
$wp_query = new WP_Query(
array(
'post_type' => 'post',
'posts_per_page' => 1,
'paged' => $paged,
)
);

add_filter(
'navigation_markup_template',
static function () {
return '<nav class="%1$s" aria-label="%4$s"><h2>%2$s</h2>%3$s</nav>';
}
);

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

$this->expectOutputString( $expected );
the_posts_navigation(
array(
'class' => 'echo-navigation',
'screen_reader_text' => 'Echo Reader',
'aria_label' => 'Echo ARIA',
)
);
}
}
Loading