diff options
author | Marc Alexander <admin@m-a-styles.de> | 2015-07-16 00:21:23 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2015-09-09 08:28:05 +0200 |
commit | 845233fc626b0d5e6d9e61039fde8e31b4dd28aa (patch) | |
tree | b035bcba8d133e726914a30a37854c2bfff4852a /tests/upload | |
parent | a09c6d1fb760151b1a6c654b597b4578c3136be1 (diff) | |
download | forums-845233fc626b0d5e6d9e61039fde8e31b4dd28aa.tar forums-845233fc626b0d5e6d9e61039fde8e31b4dd28aa.tar.gz forums-845233fc626b0d5e6d9e61039fde8e31b4dd28aa.tar.bz2 forums-845233fc626b0d5e6d9e61039fde8e31b4dd28aa.tar.xz forums-845233fc626b0d5e6d9e61039fde8e31b4dd28aa.zip |
[ticket/13904] Improve test coverage and use constants instead of magic numbers
PHPBB3-13904
Diffstat (limited to 'tests/upload')
-rw-r--r-- | tests/upload/fileupload_test.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 7a84b34473..ab42a4a153 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -119,6 +119,25 @@ class phpbb_fileupload_test extends phpbb_test_case $this->assertEquals('DISALLOWED_EXTENSION', $file->error[0]); } + public function test_common_checks_disallowed_content() + { + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); + $upload->set_allowed_extensions(array('jpg')) + ->set_max_filesize(1000); + $file = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path); + $file->set_upload_ary(array( + 'size' => 50, + 'tmp_name' => dirname(__FILE__) . '/fixture/disallowed', + 'name' => 'disallowed.jpg', + 'type' => 'image/jpg' + )) + ->set_upload_namespace($upload); + file_put_contents(dirname(__FILE__) . '/fixture/disallowed', '<body>' . file_get_contents(dirname(__FILE__) . '/fixture/jpg')); + $upload->common_checks($file); + $this->assertEquals('DISALLOWED_CONTENT', $file->error[0]); + unlink(dirname(__FILE__) . '/fixture/disallowed'); + } + public function test_common_checks_invalid_filename() { $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->request, $this->phpbb_root_path); |