diff options
Diffstat (limited to 'tests/path_helper/path_helper_test.php')
-rw-r--r-- | tests/path_helper/path_helper_test.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php index 3832307897..73f0e6bafc 100644 --- a/tests/path_helper/path_helper_test.php +++ b/tests/path_helper/path_helper_test.php @@ -411,6 +411,21 @@ class phpbb_path_helper_test extends phpbb_test_case 'http://www.phpbb.com/community', '../community/', ), + array( + 'http://www.phpbb.com/foobar', + 'http://www.phpbb.com', + '', + ), + array( + 'http://www.foobar.com', + 'http://www.phpbb.com', + '/www.phpbb.com/', + ), + array( + 'foobar', + 'http://www.phpbb.com/community', + '', + ) ); } @@ -421,4 +436,29 @@ class phpbb_path_helper_test extends phpbb_test_case { $this->assertEquals($this->phpbb_root_path . $expected, $this->path_helper->get_web_root_path_from_ajax_referer($referer_url, $board_url)); } + + public function data_get_valid_page() + { + return array( + // array( current page , mod_rewrite setting , expected output ) + array('index', true, 'index'), + array('index', false, 'index'), + array('foo/index', true, 'foo/index'), + array('foo/index', false, 'foo/index'), + array('app.php/foo', true, 'foo'), + array('app.php/foo', false, 'app.php/foo'), + array('/../app.php/foo', true, '../foo'), + array('/../app.php/foo', false, '../app.php/foo'), + array('/../example/app.php/foo/bar', true, '../example/foo/bar'), + array('/../example/app.php/foo/bar', false, '../example/app.php/foo/bar'), + ); + } + + /** + * @dataProvider data_get_valid_page + */ + public function test_get_valid_page($page, $mod_rewrite, $expected) + { + $this->assertEquals($this->phpbb_root_path . $expected, $this->path_helper->get_valid_page($page, $mod_rewrite)); + } } |