Skip to content

Commit

Permalink
Merge pull request #59 from sectsect/feature/plugin-check
Browse files Browse the repository at this point in the history
test: fix unit test for pagination
  • Loading branch information
sectsect authored Nov 30, 2024
2 parents 30f1392 + c07de62 commit 936fae7
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions tests/FunctionTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,49 @@ public function testPaginationOutput() {
$current_page = 1;
$total_pages = 5;
$range = 2;
$nonce = wp_create_nonce( 'google_ss2db_pagination' );

// Expected output.
$expected_output = '<ul class="pagination">';
$expected_output .= '<li class="current"><span>1</span></li>';
$expected_output .= '<li><a href="' . get_pagenum_link( $current_page + 1 ) . '">2</a></li>';
$expected_output .= '<li><a href="' . get_pagenum_link( $current_page + 2 ) . '">3</a></li>';
$expected_output .= '<li><a href="' . get_pagenum_link( $current_page + 3 ) . '">4</a></li>';
$expected_output .= '<li><a href="' . get_pagenum_link( $current_page + 4 ) . '">5</a></li>';
$expected_output .= '<li><a href="' . esc_url(
add_query_arg(
array(
'paged' => 2,
'nonce' => $nonce,
)
)
) . '">2</a></li>';
$expected_output .= '<li><a href="' . esc_url(
add_query_arg(
array(
'paged' => 3,
'nonce' => $nonce,
)
)
) . '">3</a></li>';
$expected_output .= '<li><a href="' . esc_url(
add_query_arg(
array(
'paged' => 4,
'nonce' => $nonce,
)
)
) . '">4</a></li>';
$expected_output .= '<li><a href="' . esc_url(
add_query_arg(
array(
'paged' => 5,
'nonce' => $nonce,
)
)
) . '">5</a></li>';
$expected_output .= '</ul>';

// Capture the output.
$this->expectOutputString( $expected_output );

// Execute the pagination function.
google_ss2db_options_pagination( $current_page, $total_pages, $range );
google_ss2db_options_pagination( $current_page, $total_pages, $range, $nonce );
}
}

0 comments on commit 936fae7

Please sign in to comment.