aboutsummaryrefslogtreecommitdiffstats
path: root/tests/upload/fileupload_test.php
diff options
context:
space:
mode:
authorTristan Darricau <github@nicofuma.fr>2014-05-28 10:53:19 +0200
committerTristan Darricau <github@nicofuma.fr>2014-05-28 10:53:19 +0200
commit6a3b343dfce3b0c758f94b8768f5a767a95f69ef (patch)
tree0e8baab283a2485943da040f1413f239358ea333 /tests/upload/fileupload_test.php
parentcee9b1d85686407276092748b93fc69cb12ddde1 (diff)
downloadforums-6a3b343dfce3b0c758f94b8768f5a767a95f69ef.tar
forums-6a3b343dfce3b0c758f94b8768f5a767a95f69ef.tar.gz
forums-6a3b343dfce3b0c758f94b8768f5a767a95f69ef.tar.bz2
forums-6a3b343dfce3b0c758f94b8768f5a767a95f69ef.tar.xz
forums-6a3b343dfce3b0c758f94b8768f5a767a95f69ef.zip
[ticket/11226] Add tests
PHPBB3-11226
Diffstat (limited to 'tests/upload/fileupload_test.php')
-rw-r--r--tests/upload/fileupload_test.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php
index 8b9df33a63..b30bfe59b4 100644
--- a/tests/upload/fileupload_test.php
+++ b/tests/upload/fileupload_test.php
@@ -103,6 +103,30 @@ 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));
+ $file->move_file('../tests/upload/fixture');
+ $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);