diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-08-22 17:00:35 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-09-25 17:34:31 +0200 |
commit | d7119a50546859f8f488e0c46ff0964362ab877a (patch) | |
tree | c055344b49d48c7ed876caf58f71f02a07e51136 | |
parent | cf46487dea0c583d58fc7ad04178841731a92e18 (diff) | |
download | forums-d7119a50546859f8f488e0c46ff0964362ab877a.tar forums-d7119a50546859f8f488e0c46ff0964362ab877a.tar.gz forums-d7119a50546859f8f488e0c46ff0964362ab877a.tar.bz2 forums-d7119a50546859f8f488e0c46ff0964362ab877a.tar.xz forums-d7119a50546859f8f488e0c46ff0964362ab877a.zip |
[ticket/11805] Add unit tests for pagination
PHPBB3-11805
-rw-r--r-- | tests/pagination/start_parameter_test.php | 111 | ||||
-rw-r--r-- | tests/pagination/templates/pagination.html | 12 |
2 files changed, 123 insertions, 0 deletions
diff --git a/tests/pagination/start_parameter_test.php b/tests/pagination/start_parameter_test.php new file mode 100644 index 0000000000..785fe80aa4 --- /dev/null +++ b/tests/pagination/start_parameter_test.php @@ -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')); + } +} diff --git a/tests/pagination/templates/pagination.html b/tests/pagination/templates/pagination.html new file mode 100644 index 0000000000..7f2a329804 --- /dev/null +++ b/tests/pagination/templates/pagination.html @@ -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 --> |