diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-05-29 00:15:10 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-05-29 00:15:10 +0200 |
commit | cae8448fe4f6c27e7c8df7a5e0e0bb4ee9bbc672 (patch) | |
tree | 57999c59795a823fca697013b15c53a7a897f1ee /tests/upload/fileupload_test.php | |
parent | 305be2ae64dc3236d9e39a97d35394ba171482b1 (diff) | |
parent | b75fb96bab92952011f796cf29611c6bff09dd37 (diff) | |
download | forums-cae8448fe4f6c27e7c8df7a5e0e0bb4ee9bbc672.tar forums-cae8448fe4f6c27e7c8df7a5e0e0bb4ee9bbc672.tar.gz forums-cae8448fe4f6c27e7c8df7a5e0e0bb4ee9bbc672.tar.bz2 forums-cae8448fe4f6c27e7c8df7a5e0e0bb4ee9bbc672.tar.xz forums-cae8448fe4f6c27e7c8df7a5e0e0bb4ee9bbc672.zip |
Merge pull request #2432 from Nicofuma/ticket/11226
[ticket/11226] filespec::move_file() should error correctly
* Nicofuma/ticket/11226:
[ticket/11226] Explicity set file_moved to false
[ticket/11226] Add tests
[ticket/11226] Use $user->lang()
[ticket/11226] filespec::move_file() should error correctly
Diffstat (limited to 'tests/upload/fileupload_test.php')
-rw-r--r-- | tests/upload/fileupload_test.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index ba7d0ea9f2..fcfb84125d 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -107,6 +107,31 @@ class phpbb_fileupload_test extends phpbb_test_case unlink($this->path . 'jpg.jpg'); } + public function test_move_existent_file() + { + $upload = new fileupload('', array('jpg'), 1000); + + copy($this->path . 'jpg', $this->path . 'jpg.jpg'); + $file = $upload->local_upload($this->path . 'jpg.jpg'); + $this->assertEquals(0, sizeof($file->error)); + $this->assertFalse($file->move_file('../tests/upload/fixture')); + $this->assertFalse($file->file_moved); + $this->assertEquals(1, sizeof($file->error)); + } + + public function test_move_existent_file_overwrite() + { + $upload = new fileupload('', array('jpg'), 1000); + + copy($this->path . 'jpg', $this->path . 'jpg.jpg'); + copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg'); + $file = $upload->local_upload($this->path . 'jpg.jpg'); + $this->assertEquals(0, sizeof($file->error)); + $file->move_file('../tests/upload/fixture/copies', true); + $this->assertEquals(0, sizeof($file->error)); + unlink($this->path . 'copies/jpg.jpg'); + } + public function test_valid_dimensions() { $upload = new fileupload('', false, false, 1, 1, 100, 100); |