diff options
author | Marc Alexander <admin@m-a-styles.de> | 2015-06-02 15:24:38 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2015-09-09 08:27:53 +0200 |
commit | 47f8f2cc88bdcd40087c8e391be1d33d36a2d308 (patch) | |
tree | fe55b0eaadda185cc8b3517b9669f7c849ac7d35 /tests | |
parent | 697ac5f4aa151b06ed65f8352652443bf297682a (diff) | |
download | forums-47f8f2cc88bdcd40087c8e391be1d33d36a2d308.tar forums-47f8f2cc88bdcd40087c8e391be1d33d36a2d308.tar.gz forums-47f8f2cc88bdcd40087c8e391be1d33d36a2d308.tar.bz2 forums-47f8f2cc88bdcd40087c8e391be1d33d36a2d308.tar.xz forums-47f8f2cc88bdcd40087c8e391be1d33d36a2d308.zip |
[ticket/13904] Pass request service to upload instead of using global
PHPBB3-13904
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functional/fileupload_remote_test.php | 12 | ||||
-rw-r--r-- | tests/upload/fileupload_test.php | 24 |
2 files changed, 21 insertions, 15 deletions
diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index ae4de26df4..4754153cbf 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -25,6 +25,9 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case /** @var \phpbb\language\language */ protected $language; + /** @var \phpbb\request\request_interface */ + protected $request; + public function setUp() { parent::setUp(); @@ -44,6 +47,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $this->request = $this->getMock('\phpbb\request\request'); $container = new phpbb_mock_container_builder(); $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language)); @@ -61,7 +65,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_invalid_extension() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); @@ -72,7 +76,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_empty_file() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_error_prefix('') ->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); @@ -83,7 +87,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_successful_upload() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(1000); @@ -95,7 +99,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_too_large() { /** @var \phpbb\files\upload $upload */ - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(100); diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 56e29a3ac2..deb4404585 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -30,11 +30,13 @@ class phpbb_fileupload_test extends phpbb_test_case /** @var \phpbb\language\language */ protected $language; + /** @var \phpbb\request\request_interface */ + protected $request; + protected function setUp() { // Global $config required by unique_id - // Global $request required by form_upload, local_upload and is_valid - global $config, $request, $phpbb_root_path, $phpEx; + global $config, $phpbb_root_path, $phpEx; if (!is_array($config)) { @@ -44,7 +46,7 @@ class phpbb_fileupload_test extends phpbb_test_case $config['rand_seed'] = ''; $config['rand_seed_last_update'] = time() + 600; - $request = new phpbb_mock_request(); + $this->request = $this->getMock('\phpbb\request\request'); $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); @@ -83,7 +85,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_extension() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('png')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -93,7 +95,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_filename() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -104,7 +106,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_too_large() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(100); $file = $this->gen_valid_filespec(); @@ -115,7 +117,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_valid_file() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); $file = $this->gen_valid_filespec(); @@ -125,7 +127,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_local_upload() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -137,7 +139,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -151,7 +153,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file_overwrite() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(array('jpg')) ->set_max_filesize(1000); @@ -166,7 +168,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_valid_dimensions() { - $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request); $upload->set_allowed_extensions(false) ->set_max_filesize(false) ->set_allowed_dimensions(1, 1, 100, 100); |