aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2015-02-03 17:53:46 +0100
committerAndreas Fischer <bantu@phpbb.com>2015-02-03 17:53:46 +0100
commit5347eac69cfd0946dadfc6c2f3cb71709ca1895c (patch)
tree29f23d62abd43db509a1deeee030ceefc02b36bb /tests
parent2864e77d6c480f8424de962dd0570185c049a9af (diff)
parenta5c65449deb98d752a4c0da86724230b4b879179 (diff)
downloadforums-5347eac69cfd0946dadfc6c2f3cb71709ca1895c.tar
forums-5347eac69cfd0946dadfc6c2f3cb71709ca1895c.tar.gz
forums-5347eac69cfd0946dadfc6c2f3cb71709ca1895c.tar.bz2
forums-5347eac69cfd0946dadfc6c2f3cb71709ca1895c.tar.xz
forums-5347eac69cfd0946dadfc6c2f3cb71709ca1895c.zip
Merge pull request #3328 from marc1706/ticket/13538
[ticket/13538] Add tests for pagination in nested loops * marc1706/ticket/13538: [ticket/13538] Add tests for double nested pagination loop [ticket/13538] Fix tests for pagination in nested loop [ticket/13538] Add test for pagination in nested loop
Diffstat (limited to 'tests')
-rw-r--r--tests/pagination/pagination_test.php36
-rw-r--r--tests/pagination/templates/pagination_double_nested.html19
-rw-r--r--tests/pagination/templates/pagination_sub.html17
3 files changed, 72 insertions, 0 deletions
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php
index 494c667198..ea6dd999c3 100644
--- a/tests/pagination/pagination_test.php
+++ b/tests/pagination/pagination_test.php
@@ -172,6 +172,42 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
$this->assertEquals(str_replace("\t", '', $expect), $this->display('test'));
}
+ /**
+ * @dataProvider generate_template_pagination_data
+ */
+ public function test_generate_template_pagination_sub($base_url, $start_name, $num_items, $per_page, $start_item, $expect)
+ {
+ // Block needs to be assigned before pagination
+ $this->template->assign_block_vars('sub', array(
+ 'FOO' => 'bar',
+ ));
+
+ $this->pagination->generate_template_pagination($base_url, 'sub.pagination', $start_name, $num_items, $per_page, $start_item);
+ $this->template->set_filenames(array('test' => 'pagination_sub.html'));
+
+ $this->assertEquals(str_replace("\t", '', $expect), $this->display('test'));
+ }
+
+ /**
+ * @dataProvider generate_template_pagination_data
+ */
+ public function test_generate_template_pagination_double_nested($base_url, $start_name, $num_items, $per_page, $start_item, $expect)
+ {
+ // Block needs to be assigned before pagination
+ $this->template->assign_block_vars('sub', array(
+ 'FOO' => 'bar',
+ ));
+
+ $this->template->assign_block_vars('sub.level2', array(
+ 'BAR' => 'foo',
+ ));
+
+ $this->pagination->generate_template_pagination($base_url, 'sub.level2.pagination', $start_name, $num_items, $per_page, $start_item);
+ $this->template->set_filenames(array('test' => 'pagination_double_nested.html'));
+
+ $this->assertEquals(str_replace("\t", '', $expect), $this->display('test'));
+ }
+
public function on_page_data()
{
return array(
diff --git a/tests/pagination/templates/pagination_double_nested.html b/tests/pagination/templates/pagination_double_nested.html
new file mode 100644
index 0000000000..c179248233
--- /dev/null
+++ b/tests/pagination/templates/pagination_double_nested.html
@@ -0,0 +1,19 @@
+pagination
+<!-- BEGIN sub -->
+<!-- BEGIN level2 -->
+:per_page:{sub.level2.PER_PAGE}
+:current_page:{sub.level2.CURRENT_PAGE}
+:base_url:{sub.level2.BASE_URL}
+<!-- BEGIN pagination -->
+<!-- IF sub.level2.pagination.S_IS_PREV -->:previous:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL}
+<!-- ELSEIF sub.level2.pagination.S_IS_CURRENT -->:current:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL}
+<!-- ELSEIF sub.level2.pagination.S_IS_ELLIPSIS -->:ellipsis:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL}
+<!-- ELSEIF sub.level2.pagination.S_IS_NEXT -->:next:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL}
+<!-- ELSE -->:else:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL}
+<!-- ENDIF -->
+<!-- END pagination -->
+<!-- IF sub.level2.U_PREVIOUS_PAGE -->:u_prev:{sub.level2.U_PREVIOUS_PAGE}<!-- ENDIF -->
+
+<!-- IF sub.level2.U_NEXT_PAGE -->:u_next:{sub.level2.U_NEXT_PAGE}<!-- ENDIF -->
+<!-- END level2 -->
+<!-- END sub -->
diff --git a/tests/pagination/templates/pagination_sub.html b/tests/pagination/templates/pagination_sub.html
new file mode 100644
index 0000000000..4ec14039e0
--- /dev/null
+++ b/tests/pagination/templates/pagination_sub.html
@@ -0,0 +1,17 @@
+pagination
+<!-- BEGIN sub -->
+:per_page:{sub.PER_PAGE}
+:current_page:{sub.CURRENT_PAGE}
+:base_url:{sub.BASE_URL}
+<!-- BEGIN pagination -->
+<!-- IF sub.pagination.S_IS_PREV -->:previous:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL}
+<!-- ELSEIF sub.pagination.S_IS_CURRENT -->:current:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL}
+<!-- ELSEIF sub.pagination.S_IS_ELLIPSIS -->:ellipsis:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL}
+<!-- ELSEIF sub.pagination.S_IS_NEXT -->:next:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL}
+<!-- ELSE -->:else:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL}
+<!-- ENDIF -->
+<!-- END pagination -->
+<!-- IF sub.U_PREVIOUS_PAGE -->:u_prev:{sub.U_PREVIOUS_PAGE}<!-- ENDIF -->
+
+<!-- IF sub.U_NEXT_PAGE -->:u_next:{sub.U_NEXT_PAGE}<!-- ENDIF -->
+<!-- END sub -->