aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2014-02-18 14:25:46 -0600
committerNathan Guse <nathaniel.guse@gmail.com>2014-02-18 14:25:46 -0600
commiteaf9a41ed8bd016880b11f480f92f1b0cfb32f84 (patch)
tree27214d0a52c9a690c2c22dbdfa7c31b75e34c546
parent7015fc8a00da40212e934ca4a499554e9289488a (diff)
parent5e1db72532aa58991a9c1d7ddba6bc5dd45ae93c (diff)
downloadforums-eaf9a41ed8bd016880b11f480f92f1b0cfb32f84.tar
forums-eaf9a41ed8bd016880b11f480f92f1b0cfb32f84.tar.gz
forums-eaf9a41ed8bd016880b11f480f92f1b0cfb32f84.tar.bz2
forums-eaf9a41ed8bd016880b11f480f92f1b0cfb32f84.tar.xz
forums-eaf9a41ed8bd016880b11f480f92f1b0cfb32f84.zip
Merge pull request #1994 from prototech/ticket/12158
[ticket/12158] The pagination start value should be 0 when there are no items.
-rw-r--r--phpBB/phpbb/pagination.php2
-rw-r--r--tests/pagination/pagination_test.php19
2 files changed, 18 insertions, 3 deletions
diff --git a/phpBB/phpbb/pagination.php b/phpBB/phpbb/pagination.php
index 8820b89431..57e7932341 100644
--- a/phpBB/phpbb/pagination.php
+++ b/phpBB/phpbb/pagination.php
@@ -251,7 +251,7 @@ class pagination
{
if ($start < 0 || $start >= $num_items)
{
- return ($start < 0) ? 0 : floor(($num_items - 1) / $per_page) * $per_page;
+ return ($start < 0 || $num_items <= 0) ? 0 : floor(($num_items - 1) / $per_page) * $per_page;
}
return $start;
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php
index 4c658cbd56..b7a4f101aa 100644
--- a/tests/pagination/pagination_test.php
+++ b/tests/pagination/pagination_test.php
@@ -159,23 +159,38 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
{
return array(
array(
+ 0,
+ 0,
+ 0,
+ ),
+ array(
-1,
+ 20,
+ 0,
+ ),
+ array(
+ 20,
+ -30,
0,
),
array(
0,
+ 20,
0,
),
array(
10,
+ 20,
10,
),
array(
20,
+ 20,
10,
),
array(
30,
+ 20,
10,
),
);
@@ -184,9 +199,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
/**
* @dataProvider validate_start_data
*/
- public function test_validate_start($start, $expect)
+ public function test_validate_start($start, $num_items, $expect)
{
- $this->assertEquals($expect, $this->pagination->validate_start($start, 10, 20));
+ $this->assertEquals($expect, $this->pagination->validate_start($start, 10, $num_items));
}
public function reverse_start_data()