From 7014d824f010ced8e9930dc149bb2cde953e3d77 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 23 Jan 2015 11:34:40 +0100 Subject: [ticket/13538] Add test for pagination in nested loop PHPBB3-13538 --- tests/pagination/pagination_test.php | 11 +++++++++++ tests/pagination/templates/pagination_sub.html | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/pagination/templates/pagination_sub.html (limited to 'tests/pagination') diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 494c667198..ca42fa806f 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -172,6 +172,17 @@ 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) + { + $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')); + } + public function on_page_data() { return array( diff --git a/tests/pagination/templates/pagination_sub.html b/tests/pagination/templates/pagination_sub.html new file mode 100644 index 0000000000..1d87940e5d --- /dev/null +++ b/tests/pagination/templates/pagination_sub.html @@ -0,0 +1,17 @@ +pagination + +:per_page:{sub.PER_PAGE} +:current_page:{sub.CURRENT_PAGE} +:base_url:{sub.BASE_URL} + +:previous:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL} +:current:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL} +:ellipsis:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL} +:next:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL} +:else:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL} + + +:u_prev:{sub.U_PREVIOUS_PAGE} + +:u_next:{sub.U_NEXT_PAGE} + -- cgit v1.2.1 From ee03b4f1efc5f8e2a6aa3352aacfff48d1609645 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 24 Jan 2015 14:27:04 +0100 Subject: [ticket/13538] Fix tests for pagination in nested loop PHPBB3-13538 --- tests/pagination/pagination_test.php | 5 +++++ tests/pagination/templates/pagination_sub.html | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'tests/pagination') diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index ca42fa806f..a37d34ad1b 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -177,6 +177,11 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case */ 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')); diff --git a/tests/pagination/templates/pagination_sub.html b/tests/pagination/templates/pagination_sub.html index 1d87940e5d..4ec14039e0 100644 --- a/tests/pagination/templates/pagination_sub.html +++ b/tests/pagination/templates/pagination_sub.html @@ -11,7 +11,7 @@ pagination :else:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL} -:u_prev:{sub.U_PREVIOUS_PAGE} +:u_prev:{sub.U_PREVIOUS_PAGE} -:u_next:{sub.U_NEXT_PAGE} +:u_next:{sub.U_NEXT_PAGE} -- cgit v1.2.1 From a5c65449deb98d752a4c0da86724230b4b879179 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 24 Jan 2015 14:35:49 +0100 Subject: [ticket/13538] Add tests for double nested pagination loop PHPBB3-13538 --- tests/pagination/pagination_test.php | 20 ++++++++++++++++++++ .../templates/pagination_double_nested.html | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/pagination/templates/pagination_double_nested.html (limited to 'tests/pagination') diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index a37d34ad1b..ea6dd999c3 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -188,6 +188,26 @@ 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_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 + + +:per_page:{sub.level2.PER_PAGE} +:current_page:{sub.level2.CURRENT_PAGE} +:base_url:{sub.level2.BASE_URL} + +:previous:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL} +:current:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL} +:ellipsis:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL} +:next:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL} +:else:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL} + + +:u_prev:{sub.level2.U_PREVIOUS_PAGE} + +:u_next:{sub.level2.U_NEXT_PAGE} + + -- cgit v1.2.1