mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Merge pull request #1994 from prototech/ticket/12158
[ticket/12158] The pagination start value should be 0 when there are no items.
This commit is contained in:
commit
eaf9a41ed8
2 changed files with 18 additions and 3 deletions
|
@ -251,7 +251,7 @@ class pagination
|
||||||
{
|
{
|
||||||
if ($start < 0 || $start >= $num_items)
|
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;
|
return $start;
|
||||||
|
|
|
@ -158,24 +158,39 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
|
||||||
public function validate_start_data()
|
public function validate_start_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
array(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
-1,
|
-1,
|
||||||
|
20,
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
20,
|
||||||
|
-30,
|
||||||
0,
|
0,
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
0,
|
0,
|
||||||
|
20,
|
||||||
0,
|
0,
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
10,
|
10,
|
||||||
|
20,
|
||||||
10,
|
10,
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
|
20,
|
||||||
20,
|
20,
|
||||||
10,
|
10,
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
30,
|
30,
|
||||||
|
20,
|
||||||
10,
|
10,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -184,9 +199,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
|
||||||
/**
|
/**
|
||||||
* @dataProvider validate_start_data
|
* @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()
|
public function reverse_start_data()
|
||||||
|
|
Loading…
Add table
Reference in a new issue