diff options
Diffstat (limited to 'tests/pagination/pagination_test.php')
-rw-r--r-- | tests/pagination/pagination_test.php | 80 |
1 files changed, 60 insertions, 20 deletions
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 4e8083b47f..71206dff58 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -21,11 +21,27 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case public function setUp() { parent::setUp(); - $user = $this->getMock('\phpbb\user'); - $user->expects($this->any()) + + global $phpbb_dispatcher; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher; + $this->user = $this->getMock('\phpbb\user'); + $this->user->expects($this->any()) ->method('lang') ->will($this->returnCallback(array($this, 'return_callback_implode'))); - $this->pagination = new \phpbb\pagination($this->template, $user); + + $this->finder = new \phpbb\extension\finder( + new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()), + new \phpbb\filesystem(), + dirname(__FILE__) . '/', + new phpbb_mock_cache() + ); + + $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); + $provider = new \phpbb\controller\provider($this->finder); + $provider->find(dirname(__FILE__) . '/'); + $this->helper = new \phpbb\controller\helper($this->template, $this->user, $this->config, $provider, '', 'php'); + $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper); } public function generate_template_pagination_data() @@ -38,6 +54,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case 10, 10, 'pagination + :per_page:10 + :current_page:2 + :base_url:page.php :previous::page.php :else:1:page.php :current:2:page.php?start=10 @@ -57,6 +76,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case 10, 20, 'pagination + :per_page:10 + :current_page:3 + :base_url:page.php :previous::page.php?start=10 :else:1:page.php :else:2:page.php?start=10 @@ -71,12 +93,18 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case :u_next:page.php?start=30', ), array( - 'test/page/%d', - '/page/%d', + array('routes' => array( + 'core_controller', + 'core_page_controller', + )), + 'page', 95, 10, 10, 'pagination + :per_page:10 + :current_page:2 + :base_url: :previous::test :else:1:test :current:2:test/page/2 @@ -90,12 +118,18 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case :u_next:test/page/3', ), array( - 'test/page/%d', - '/page/%d', + array('routes' => array( + 'core_controller', + 'core_page_controller', + )), + 'page', 95, 10, 20, 'pagination + :per_page:10 + :current_page:3 + :base_url: :previous::test/page/2 :else:1:test :else:2:test/page/2 @@ -127,15 +161,10 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case { return array( array( - 'page.php', 10, 10, 0, 'PAGE_OF-1-1', - 'on_page - per_page:10 - on_page:1 - base_url:page.php', ), ); } @@ -143,36 +172,47 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case /** * @dataProvider on_page_data */ - public function test_on_page($base_url, $num_items, $per_page, $start_item, $expect_return, $expect) + public function test_on_page($num_items, $per_page, $start_item, $expect_return) { - $this->assertEquals($expect_return, $this->pagination->on_page($base_url, $num_items, $per_page, $start_item)); - - $this->template->set_filenames(array('test' => 'on_page.html')); - - $this->assertEquals(str_replace("\t", '', $expect), $this->display('test')); + $this->assertEquals($expect_return, $this->pagination->on_page($num_items, $per_page, $start_item)); } public function validate_start_data() { return array( array( + 0, + 0, + 0, + ), + array( -1, + 20, 0, ), array( + 20, + -30, 0, + ), + array( + 0, + 20, 0, ), array( 10, + 20, 10, ), array( 20, + 20, 10, ), array( 30, + 20, 10, ), ); @@ -181,9 +221,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case /** * @dataProvider validate_start_data */ - public function test_validate_start($start, $expect) + public function test_validate_start($start, $num_items, $expect) { - $this->assertEquals($expect, $this->pagination->validate_start($start, 10, 20)); + $this->assertEquals($expect, $this->pagination->validate_start($start, 10, $num_items)); } public function reverse_start_data() |