aboutsummaryrefslogtreecommitdiffstats
path: root/tests/pagination
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2013-11-22 17:15:33 +0100
committerJoas Schilling <nickvergessen@gmx.de>2013-12-18 18:34:13 +0100
commit268afe20f4796fc2830a43576a686fd99bc5c508 (patch)
tree96d6acd52169aa2f44d27e7e0d84e0900b1d3f10 /tests/pagination
parent5220013f9da1b317aa2961196323c08c70b1df24 (diff)
downloadforums-268afe20f4796fc2830a43576a686fd99bc5c508.tar
forums-268afe20f4796fc2830a43576a686fd99bc5c508.tar.gz
forums-268afe20f4796fc2830a43576a686fd99bc5c508.tar.bz2
forums-268afe20f4796fc2830a43576a686fd99bc5c508.tar.xz
forums-268afe20f4796fc2830a43576a686fd99bc5c508.zip
[ticket/11849] Move pagination code to class
PHPBB3-11849
Diffstat (limited to 'tests/pagination')
-rw-r--r--tests/pagination/pagination_test.php117
1 files changed, 117 insertions, 0 deletions
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php
new file mode 100644
index 0000000000..567fddc25d
--- /dev/null
+++ b/tests/pagination/pagination_test.php
@@ -0,0 +1,117 @@
+<?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__) . '/../template/template_test_case.php';
+
+class phpbb_pagination_pagination_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)
+ {
+ $pagination = new \phpbb\pagination($this->template, $this->getMock('\phpbb\user'));
+ $pagination->set_per_page($per_page)
+ ->set_num_items($num_items)
+ ->set_start_name($start_name)
+ ->set_base_url($base_url)
+ ->set_template_block_name('pagination');
+
+ $pagination->generate_template_pagination($start_item);
+ $this->template->set_filenames(array('test' => 'pagination.html'));
+
+ $this->assertEquals(str_replace("\t", '', $expect), $this->display('test'));
+ }
+}