mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/11805] Add unit tests for pagination
PHPBB3-11805
This commit is contained in:
parent
cf46487dea
commit
d7119a5054
2 changed files with 123 additions and 0 deletions
111
tests/pagination/start_parameter_test.php
Normal file
111
tests/pagination/start_parameter_test.php
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2013 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||||
|
require_once dirname(__FILE__) . '/../template/template_test_case.php';
|
||||||
|
|
||||||
|
class phpbb_pagination_start_parameter_test extends phpbb_template_template_test_case
|
||||||
|
{
|
||||||
|
protected $test_path = 'tests/pagination';
|
||||||
|
|
||||||
|
public function phpbb_generate_template_pagination_data()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'page.php',
|
||||||
|
'start',
|
||||||
|
95,
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
'pagination
|
||||||
|
:previous::page.php
|
||||||
|
:else:1:page.php
|
||||||
|
:current:2:page.php?start=10
|
||||||
|
:else:3:page.php?start=20
|
||||||
|
:else:4:page.php?start=30
|
||||||
|
:else:5:page.php?start=40
|
||||||
|
:ellipsis:9:page.php?start=80
|
||||||
|
:else:10:page.php?start=90
|
||||||
|
:next::page.php?start=20
|
||||||
|
:u_prev:page.php
|
||||||
|
:u_next:page.php?start=20',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'page.php',
|
||||||
|
'start',
|
||||||
|
95,
|
||||||
|
10,
|
||||||
|
20,
|
||||||
|
'pagination
|
||||||
|
:previous::page.php?start=10
|
||||||
|
:else:1:page.php
|
||||||
|
:else:2:page.php?start=10
|
||||||
|
:current:3:page.php?start=20
|
||||||
|
:else:4:page.php?start=30
|
||||||
|
:else:5:page.php?start=40
|
||||||
|
:else:6:page.php?start=50
|
||||||
|
:ellipsis:9:page.php?start=80
|
||||||
|
:else:10:page.php?start=90
|
||||||
|
:next::page.php?start=30
|
||||||
|
:u_prev:page.php?start=10
|
||||||
|
:u_next:page.php?start=30',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'test/page/%d',
|
||||||
|
'/page/%d',
|
||||||
|
95,
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
'pagination
|
||||||
|
:previous::test
|
||||||
|
:else:1:test
|
||||||
|
:current:2:test/page/2
|
||||||
|
:else:3:test/page/3
|
||||||
|
:else:4:test/page/4
|
||||||
|
:else:5:test/page/5
|
||||||
|
:ellipsis:9:test/page/9
|
||||||
|
:else:10:test/page/10
|
||||||
|
:next::test/page/3
|
||||||
|
:u_prev:test
|
||||||
|
:u_next:test/page/3',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'test/page/%d',
|
||||||
|
'/page/%d',
|
||||||
|
95,
|
||||||
|
10,
|
||||||
|
20,
|
||||||
|
'pagination
|
||||||
|
:previous::test/page/2
|
||||||
|
:else:1:test
|
||||||
|
:else:2:test/page/2
|
||||||
|
:current:3:test/page/3
|
||||||
|
:else:4:test/page/4
|
||||||
|
:else:5:test/page/5
|
||||||
|
:else:6:test/page/6
|
||||||
|
:ellipsis:9:test/page/9
|
||||||
|
:else:10:test/page/10
|
||||||
|
:next::test/page/4
|
||||||
|
:u_prev:test/page/2
|
||||||
|
:u_next:test/page/4',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider phpbb_generate_template_pagination_data
|
||||||
|
*/
|
||||||
|
public function test_phpbb_generate_template_pagination($base_url, $start_name, $num_items, $per_page, $start_item, $expect)
|
||||||
|
{
|
||||||
|
phpbb_generate_template_pagination($this->template, $base_url, 'pagination', $start_name, $num_items, $per_page, $start_item);
|
||||||
|
$this->template->set_filenames(array('test' => 'pagination.html'));
|
||||||
|
|
||||||
|
$this->assertEquals(str_replace("\t", '', $expect), $this->display('test'));
|
||||||
|
}
|
||||||
|
}
|
12
tests/pagination/templates/pagination.html
Normal file
12
tests/pagination/templates/pagination.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
pagination
|
||||||
|
<!-- BEGIN pagination -->
|
||||||
|
<!-- IF pagination.S_IS_PREV -->:previous:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL}
|
||||||
|
<!-- ELSEIF pagination.S_IS_CURRENT -->:current:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL}
|
||||||
|
<!-- ELSEIF pagination.S_IS_ELLIPSIS -->:ellipsis:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL}
|
||||||
|
<!-- ELSEIF pagination.S_IS_NEXT -->:next:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL}
|
||||||
|
<!-- ELSE -->:else:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL}
|
||||||
|
<!-- ENDIF -->
|
||||||
|
<!-- END pagination -->
|
||||||
|
<!-- IF U_PREVIOUS_PAGE -->:u_prev:{U_PREVIOUS_PAGE}<!-- ENDIF -->
|
||||||
|
|
||||||
|
<!-- IF U_NEXT_PAGE -->:u_next:{U_NEXT_PAGE}<!-- ENDIF -->
|
Loading…
Add table
Reference in a new issue