diff options
author | MateBartus <mate.bartus@gmail.com> | 2015-03-12 00:25:00 +0100 |
---|---|---|
committer | MateBartus <mate.bartus@gmail.com> | 2015-04-16 13:24:10 +0200 |
commit | 4bdef6fd21a5dcab455b0cd1ee2652de606929c3 (patch) | |
tree | 33eae92e90b43770b2c1e2e4508dbcf35d6bd7da /tests/upload/fileupload_test.php | |
parent | f86c5d905bb82967505ef3e07fa429b59c112871 (diff) | |
download | forums-4bdef6fd21a5dcab455b0cd1ee2652de606929c3.tar forums-4bdef6fd21a5dcab455b0cd1ee2652de606929c3.tar.gz forums-4bdef6fd21a5dcab455b0cd1ee2652de606929c3.tar.bz2 forums-4bdef6fd21a5dcab455b0cd1ee2652de606929c3.tar.xz forums-4bdef6fd21a5dcab455b0cd1ee2652de606929c3.zip |
[ticket/13697] Moving filesystem related functions to filesystem service
* Moving filesystem service to \phpbb\filesystem namespace
* Wraping Symfony's Filesystem component
* Moving filesystem related functions from includes/functions.php
into \phpbb\filesystem\filesystem
Functions moved (and deprecated):
- phpbb_chmod
- phpbb_is_writable
- phpbb_is_absolute
- phpbb_own_realpath
- phpbb_realpath
* Adding interface for filesystem service
PHPBB3-13697
Diffstat (limited to 'tests/upload/fileupload_test.php')
-rw-r--r-- | tests/upload/fileupload_test.php | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index fcfb84125d..9de384b64f 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -20,12 +20,14 @@ class phpbb_fileupload_test extends phpbb_test_case { private $path; + private $filesystem; + protected function setUp() { // Global $config required by unique_id // Global $user required by several functions dealing with translations // Global $request required by form_upload, local_upload and is_valid - global $config, $user, $request; + global $config, $user, $request, $phpbb_filesystem; if (!is_array($config)) { @@ -40,6 +42,8 @@ class phpbb_fileupload_test extends phpbb_test_case $request = new phpbb_mock_request(); + $this->filesystem = $phpbb_filesystem = new \phpbb\filesystem\filesystem(); + $this->path = __DIR__ . '/fixture/'; } @@ -65,7 +69,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_extension() { - $upload = new fileupload('', array('png'), 100); + $upload = new fileupload($this->filesystem, '', array('png'), 100); $file = $this->gen_valid_filespec(); $upload->common_checks($file); $this->assertEquals('DISALLOWED_EXTENSION', $file->error[0]); @@ -73,7 +77,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_invalid_filename() { - $upload = new fileupload('', array('jpg'), 100); + $upload = new fileupload($this->filesystem, '', array('jpg'), 100); $file = $this->gen_valid_filespec(); $file->realname = 'invalid?'; $upload->common_checks($file); @@ -82,7 +86,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_too_large() { - $upload = new fileupload('', array('jpg'), 100); + $upload = new fileupload($this->filesystem, '', array('jpg'), 100); $file = $this->gen_valid_filespec(); $file->filesize = 1000; $upload->common_checks($file); @@ -91,7 +95,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_common_checks_valid_file() { - $upload = new fileupload('', array('jpg'), 1000); + $upload = new fileupload($this->filesystem, '', array('jpg'), 1000); $file = $this->gen_valid_filespec(); $upload->common_checks($file); $this->assertEquals(0, sizeof($file->error)); @@ -99,7 +103,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_local_upload() { - $upload = new fileupload('', array('jpg'), 1000); + $upload = new fileupload($this->filesystem, '', array('jpg'), 1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); $file = $upload->local_upload($this->path . 'jpg.jpg'); @@ -109,7 +113,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file() { - $upload = new fileupload('', array('jpg'), 1000); + $upload = new fileupload($this->filesystem, '', array('jpg'), 1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); $file = $upload->local_upload($this->path . 'jpg.jpg'); @@ -121,7 +125,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_move_existent_file_overwrite() { - $upload = new fileupload('', array('jpg'), 1000); + $upload = new fileupload($this->filesystem, '', array('jpg'), 1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg'); @@ -134,7 +138,7 @@ class phpbb_fileupload_test extends phpbb_test_case public function test_valid_dimensions() { - $upload = new fileupload('', false, false, 1, 1, 100, 100); + $upload = new fileupload($this->filesystem, '', false, false, 1, 1, 100, 100); $file1 = $this->gen_valid_filespec(); $file2 = $this->gen_valid_filespec(); |