Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/helpers/pagination-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function get_key_query_loop() {
/**
* Returns the page number from the query loop.
*
* @return string The page number from the query loop.
* @return int|string The page number from the query loop, or an empty string when none applies.
*/
public function get_page_number_from_query_loop() {
$key_query_loop = $this->get_key_query_loop();
Expand Down
20 changes: 20 additions & 0 deletions tests/Unit/Helpers/Pagination_Helper_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,4 +623,24 @@ public function test_get_page_number_from_query_loop( $key, $value, $expects ) {

$this->assertEquals( $expects, $this->instance->get_page_number_from_query_loop() );
}

/**
* @covers ::get_page_number_from_query_loop
*
* @return void
*/
public function test_query_loop_page_number_returns_int_when_above_one() {
$_GET = [ 'query-1-page' => '2' ];
$this->assertSame( 2, $this->instance->get_page_number_from_query_loop() );
}

/**
* @covers ::get_page_number_from_query_loop
*
* @return void
*/
public function test_query_loop_page_number_returns_empty_string_when_absent() {
$_GET = [];
$this->assertSame( '', $this->instance->get_page_number_from_query_loop() );
}
}
Loading