From e964c488a2cd09de2f4b6cc3313abce9fbb1ef74 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 25 Nov 2026 14:53:56 +0530 Subject: [PATCH 1/4] Tests: Cover the early return in `paginate_links()` when total is less than 2 --- tests/phpunit/tests/general/paginateLinks.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/phpunit/tests/general/paginateLinks.php b/tests/phpunit/tests/general/paginateLinks.php index fb99e86e0f459..02c1445fc5f82 100644 --- a/tests/phpunit/tests/general/paginateLinks.php +++ b/tests/phpunit/tests/general/paginateLinks.php @@ -565,4 +565,37 @@ public static function data_query_strings(): array { 'multi query vars' => array( 'foo=bar&pen=pencil' ), ); } + + /** + * Tests that paginate_links() returns null when there are fewer than two pages. + * + * @ticket 66757 + * + * @dataProvider data_total_less_than_two + * + * @param int|string $total Total pages passed to paginate_links(). + */ + public function test_paginate_links_returns_null_when_total_less_than_two( $total ) { + $this->assertNull( + paginate_links( + array( + 'total' => $total, + ) + ) + ); + } + + /** + * Data provider for test_paginate_links_returns_null_when_total_less_than_two(). + * + * @return array[] + */ + public static function data_total_less_than_two() { + return array( + 'zero' => array( 0 ), + 'one' => array( 1 ), + 'string zero' => array( '0' ), + 'string one' => array( '1' ), + ); + } } From 2e016ef67d499362ca337ff6d040860c3f4b74de Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Thu, 26 Nov 2026 09:32:11 +0530 Subject: [PATCH 2/4] Refactor test for paginate_links() to use single page --- tests/phpunit/tests/general/paginateLinks.php | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/tests/phpunit/tests/general/paginateLinks.php b/tests/phpunit/tests/general/paginateLinks.php index 02c1445fc5f82..513b24bdd42c1 100644 --- a/tests/phpunit/tests/general/paginateLinks.php +++ b/tests/phpunit/tests/general/paginateLinks.php @@ -567,35 +567,17 @@ public static function data_query_strings(): array { } /** - * Tests that paginate_links() returns null when there are fewer than two pages. + * Tests that paginate_links() returns null when there is only one page. * * @ticket 66757 - * - * @dataProvider data_total_less_than_two - * - * @param int|string $total Total pages passed to paginate_links(). */ - public function test_paginate_links_returns_null_when_total_less_than_two( $total ) { + public function test_paginate_links_returns_null_when_total_less_than_two() { $this->assertNull( paginate_links( array( - 'total' => $total, + 'total' => '1', ) ) ); } - - /** - * Data provider for test_paginate_links_returns_null_when_total_less_than_two(). - * - * @return array[] - */ - public static function data_total_less_than_two() { - return array( - 'zero' => array( 0 ), - 'one' => array( 1 ), - 'string zero' => array( '0' ), - 'string one' => array( '1' ), - ); - } } From 042a986a2a343c1e0c4f6795cbcbf1f371945f1a Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Thu, 26 Nov 2026 09:37:12 +0530 Subject: [PATCH 3/4] Update ticket reference in paginateLinks test --- tests/phpunit/tests/general/paginateLinks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/general/paginateLinks.php b/tests/phpunit/tests/general/paginateLinks.php index 513b24bdd42c1..4f7eeee660491 100644 --- a/tests/phpunit/tests/general/paginateLinks.php +++ b/tests/phpunit/tests/general/paginateLinks.php @@ -569,7 +569,7 @@ public static function data_query_strings(): array { /** * Tests that paginate_links() returns null when there is only one page. * - * @ticket 66757 + * @ticket 66827 */ public function test_paginate_links_returns_null_when_total_less_than_two() { $this->assertNull( From ff330980b38090ea12e72b7f2fd012a8689f469c Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Thu, 26 Nov 2026 20:04:30 +0530 Subject: [PATCH 4/4] Updated name in docblock Co-authored-by: Mukesh Panchal --- tests/phpunit/tests/general/paginateLinks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/general/paginateLinks.php b/tests/phpunit/tests/general/paginateLinks.php index 4f7eeee660491..26dd000fac1c0 100644 --- a/tests/phpunit/tests/general/paginateLinks.php +++ b/tests/phpunit/tests/general/paginateLinks.php @@ -571,7 +571,7 @@ public static function data_query_strings(): array { * * @ticket 66827 */ - public function test_paginate_links_returns_null_when_total_less_than_two() { + public function test_paginate_links_returns_null_for_a_single_page() { $this->assertNull( paginate_links( array(