diff options
author | Marc Alexander <admin@m-a-styles.de> | 2014-06-26 15:07:05 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2014-06-26 15:07:05 +0200 |
commit | 9b27d00d5fc8228ec4f9150aa26bcf450dc45524 (patch) | |
tree | e2c97576903b834d04178c6d15db419bbd3497c2 /tests/path_helper/path_helper_test.php | |
parent | 69b9aa2859441116c02ea0b36f6f3a53b8c1eda1 (diff) | |
parent | e71f65c2bb8a810f669b275856cf7e3654d34810 (diff) | |
download | forums-9b27d00d5fc8228ec4f9150aa26bcf450dc45524.tar forums-9b27d00d5fc8228ec4f9150aa26bcf450dc45524.tar.gz forums-9b27d00d5fc8228ec4f9150aa26bcf450dc45524.tar.bz2 forums-9b27d00d5fc8228ec4f9150aa26bcf450dc45524.tar.xz forums-9b27d00d5fc8228ec4f9150aa26bcf450dc45524.zip |
Merge remote-tracking branch 'nickvergessen/ticket/12099' into develop-ascraeus
* nickvergessen/ticket/12099:
[ticket/12099] Fix correction in path_helper test
[ticket/12099] Prepend ./ to path to fix assets
[ticket/12099] Deduplicate path generation
[ticket/12099] Fix clean_path() ".." stripping when previous directory was "."
[ticket/12099] Break clean_path tests with a simple test
[ticket/12099] Clean paths in tests
[ticket/12099] Correctly fix go back to root before prepending the root path
[ticket/12099] Clean some paths before using them
[ticket/12099] Fix several issues in path_helper test
Diffstat (limited to 'tests/path_helper/path_helper_test.php')
-rw-r--r-- | tests/path_helper/path_helper_test.php | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php index a3ad901379..9866cb6efe 100644 --- a/tests/path_helper/path_helper_test.php +++ b/tests/path_helper/path_helper_test.php @@ -13,6 +13,7 @@ class phpbb_path_helper_test extends phpbb_test_case { + /** @var \phpbb\path_helper */ protected $path_helper; protected $phpbb_root_path = ''; @@ -20,7 +21,8 @@ class phpbb_path_helper_test extends phpbb_test_case { parent::setUp(); - $this->set_phpbb_root_path(); + $filesystem = new \phpbb\filesystem(); + $this->set_phpbb_root_path($filesystem); $this->path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( @@ -40,9 +42,9 @@ class phpbb_path_helper_test extends phpbb_test_case * any time we wish to use it in one of these functions (and * also in general for everything else) */ - public function set_phpbb_root_path() + public function set_phpbb_root_path($filesystem) { - $this->phpbb_root_path = dirname(__FILE__) . './../../phpBB/'; + $this->phpbb_root_path = $filesystem->clean_path(dirname(__FILE__) . '/../../phpBB/'); } public function test_get_web_root_path() @@ -53,7 +55,8 @@ class phpbb_path_helper_test extends phpbb_test_case public function basic_update_web_root_path_data() { - $this->set_phpbb_root_path(); + $filesystem = new \phpbb\filesystem(); + $this->set_phpbb_root_path($filesystem); return array( array( @@ -71,7 +74,7 @@ class phpbb_path_helper_test extends phpbb_test_case ), array( $this->phpbb_root_path . $this->phpbb_root_path . 'test.php', - $this->phpbb_root_path . $this->phpbb_root_path . 'test.php', + $filesystem->clean_path($this->phpbb_root_path . $this->phpbb_root_path . 'test.php'), ), ); } @@ -81,51 +84,55 @@ class phpbb_path_helper_test extends phpbb_test_case */ public function test_basic_update_web_root_path($input, $expected) { - $this->assertEquals($expected, $this->path_helper->update_web_root_path($input, $symfony_request)); + $this->assertEquals($expected, $this->path_helper->update_web_root_path($input)); } public function update_web_root_path_data() { - $this->set_phpbb_root_path(); + $this->set_phpbb_root_path(new \phpbb\filesystem()); return array( array( $this->phpbb_root_path . 'test.php', - $this->phpbb_root_path . 'test.php', '/', + null, + null, + '', ), array( $this->phpbb_root_path . 'test.php', - $this->phpbb_root_path . '../test.php', '//', + null, + null, + './../', ), array( $this->phpbb_root_path . 'test.php', - $this->phpbb_root_path . '../test.php', '//', 'foo/bar.php', 'bar.php', + './../', ), array( $this->phpbb_root_path . 'test.php', - $this->phpbb_root_path . '../../test.php', '/foo/template', '/phpbb3-fork/phpBB/app.php/foo/template', '/phpbb3-fork/phpBB/app.php', + './../../', ), array( $this->phpbb_root_path . 'test.php', - $this->phpbb_root_path . '../test.php', '/foo/template', '/phpbb3-fork/phpBB/foo/template', '/phpbb3-fork/phpBB/app.php', + './../', ), array( $this->phpbb_root_path . 'test.php', - $this->phpbb_root_path . '../test.php', '/', '/phpbb3-fork/phpBB/app.php/', '/phpbb3-fork/phpBB/app.php', + './../', ), ); } @@ -133,9 +140,9 @@ class phpbb_path_helper_test extends phpbb_test_case /** * @dataProvider update_web_root_path_data */ - public function test_update_web_root_path($input, $expected, $getPathInfo, $getRequestUri = null, $getScriptName = null) + public function test_update_web_root_path($input, $getPathInfo, $getRequestUri, $getScriptName, $correction) { - $symfony_request = $this->getMock("\phpbb\symfony_request", array(), array( + $symfony_request = $this->getMock('\phpbb\symfony_request', array(), array( new phpbb_mock_request(), )); $symfony_request->expects($this->any()) @@ -155,7 +162,7 @@ class phpbb_path_helper_test extends phpbb_test_case 'php' ); - $this->assertEquals($expected, $path_helper->update_web_root_path($input, $symfony_request)); + $this->assertEquals($correction . $input, $path_helper->update_web_root_path($input, $symfony_request)); } public function clean_url_data() |